-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking changes: * renamed `Tracer` to `ConnectivityTracer` * renamed `connectivity(f, x)` to `pattern(f, T, x)`, where `T` is a tracer type * renamed `connectivity(f!, y, x)` to `pattern(f!, y, T, x)`, where `T` is a tracer type * `trace_input(x)` has been replaced by `trace_input(T, x)`, where `T` is a tracer type
- Loading branch information
Showing
19 changed files
with
421 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "SparseConnectivityTracer" | ||
uuid = "9f842d2f-2579-4b1d-911e-f412cf18a3f5" | ||
authors = ["Adrian Hill <[email protected]>"] | ||
version = "0.1.0" | ||
version = "0.2.0-DEV" | ||
|
||
[deps] | ||
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
## Type conversions | ||
Base.promote_rule(::Type{Tracer}, ::Type{N}) where {N<:Number} = Tracer | ||
Base.promote_rule(::Type{N}, ::Type{Tracer}) where {N<:Number} = Tracer | ||
for T in (:JacobianTracer, :ConnectivityTracer) | ||
@eval Base.promote_rule(::Type{$T}, ::Type{N}) where {N<:Number} = $T | ||
@eval Base.promote_rule(::Type{N}, ::Type{$T}) where {N<:Number} = $T | ||
|
||
Base.big(::Type{Tracer}) = Tracer | ||
Base.widen(::Type{Tracer}) = Tracer | ||
Base.widen(t::Tracer) = t | ||
@eval Base.big(::Type{$T}) = $T | ||
@eval Base.widen(::Type{$T}) = $T | ||
@eval Base.widen(t::$T) = t | ||
|
||
Base.convert(::Type{Tracer}, x::Number) = EMPTY_TRACER | ||
Base.convert(::Type{Tracer}, t::Tracer) = t | ||
Base.convert(::Type{<:Number}, t::Tracer) = t | ||
@eval Base.convert(::Type{$T}, x::Number) = empty($T) | ||
@eval Base.convert(::Type{$T}, t::$T) = t | ||
@eval Base.convert(::Type{<:Number}, t::$T) = t | ||
|
||
## Array constructors | ||
Base.zero(::Type{Tracer}) = EMPTY_TRACER | ||
Base.one(::Type{Tracer}) = EMPTY_TRACER | ||
## Array constructors | ||
@eval Base.zero(::Type{$T}) = empty($T) | ||
@eval Base.one(::Type{$T}) = empty($T) | ||
|
||
Base.similar(a::Array{Tracer,1}) = zeros(Tracer, size(a, 1)) | ||
Base.similar(a::Array{Tracer,2}) = zeros(Tracer, size(a, 1), size(a, 2)) | ||
Base.similar(a::Array{T,1}, ::Type{Tracer}) where {T} = zeros(Tracer, size(a, 1)) | ||
Base.similar(a::Array{T,2}, ::Type{Tracer}) where {T} = zeros(Tracer, size(a, 1), size(a, 2)) | ||
Base.similar(::Array{Tracer}, m::Int) = zeros(Tracer, m) | ||
Base.similar(::Array, ::Type{Tracer}, dims::Dims{N}) where {N} = zeros(Tracer, dims) | ||
Base.similar(::Array{Tracer}, dims::Dims{N}) where {N} = zeros(Tracer, dims) | ||
@eval Base.similar(a::Array{$T,1}) = zeros($T, size(a, 1)) | ||
@eval Base.similar(a::Array{$T,2}) = zeros($T, size(a, 1), size(a, 2)) | ||
@eval Base.similar(a::Array{A,1}, ::Type{$T}) where {A} = zeros($T, size(a, 1)) | ||
@eval Base.similar(a::Array{A,2}, ::Type{$T}) where {A} = zeros($T, size(a, 1), size(a, 2)) | ||
@eval Base.similar(::Array{$T}, m::Int) = zeros($T, m) | ||
@eval Base.similar(::Array, ::Type{$T}, dims::Dims{N}) where {N} = zeros($T, dims) | ||
@eval Base.similar(::Array{$T}, dims::Dims{N}) where {N} = zeros($T, dims) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
for fn in union(ops_1_to_1_s, ops_1_to_1_f, ops_1_to_1_z) | ||
@eval Base.$fn(t::ConnectivityTracer) = t | ||
end | ||
|
||
for fn in ops_1_to_1_const | ||
@eval Base.$fn(::ConnectivityTracer) = EMPTY_CONNECTIVITY_TRACER | ||
end | ||
|
||
for fn in ops_1_to_2 | ||
@eval Base.$fn(t::ConnectivityTracer) = (t, t) | ||
end | ||
|
||
for fn in ops_2_to_1 | ||
@eval Base.$fn(a::ConnectivityTracer, b::ConnectivityTracer) = uniontracer(a, b) | ||
@eval Base.$fn(t::ConnectivityTracer, ::Number) = t | ||
@eval Base.$fn(::Number, t::ConnectivityTracer) = t | ||
end | ||
|
||
# Extra types required for exponent | ||
Base.:^(a::ConnectivityTracer, b::ConnectivityTracer) = uniontracer(a, b) | ||
for T in (:Real, :Integer, :Rational) | ||
@eval Base.:^(t::ConnectivityTracer, ::$T) = t | ||
@eval Base.:^(::$T, t::ConnectivityTracer) = t | ||
end | ||
Base.:^(t::ConnectivityTracer, ::Irrational{:ℯ}) = t | ||
Base.:^(::Irrational{:ℯ}, t::ConnectivityTracer) = t | ||
|
||
## Rounding | ||
Base.round(t::ConnectivityTracer, ::RoundingMode; kwargs...) = t | ||
|
||
## Random numbers | ||
rand(::AbstractRNG, ::SamplerType{ConnectivityTracer}) = EMPTY_CONNECTIVITY_TRACER |
Oops, something went wrong.