Skip to content

Commit

Permalink
Merge pull request #13 from rmsrosa/dev
Browse files Browse the repository at this point in the history
support math functions on NeuralNumbers
  • Loading branch information
rmsrosa authored Jul 22, 2023
2 parents d2ddfd1 + 987ccd6 commit 51f49c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main
pull_request:
branches:
- master
- main
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ChainPlots"
uuid = "43761bbe-b505-42c3-b8bd-5d4ae40fd227"
authors = ["Ricardo Rosa <[email protected]>"]
version = "0.1.2"
version = "0.1.3"

[deps]
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand Down
15 changes: 10 additions & 5 deletions src/NeuralNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,22 @@ Base.promote_rule(::Type{NeuralNumber}, ::Type{<:Number}) = NeuralNumber

Random.rand(::Random.AbstractRNG, ::Random.Sampler{NeuralNumber}) = cold

for f in [:+, :-, :abs, :abs2, :inv, :tanh, :sqrt,
:exp, :log, :log1p, :log2, :log10,
:conj, :transpose, :adjoint, :angle]
for f in (:log, :exp, :sin, :cos, :tan, :sinh, :cosh, :tanh, :asin,
:acos, :atan, :asinh, :acosh, :atanh, :cbrt, :sqrt, :log2, :log10,
:max, :min, :exp2, :exp10, :expm1, :log1p, :sinpi, :cospi, :mod2pi,
)
@eval Base.$f(x::NeuralNumber) = x
end

for f in [:+, :-, :*, :/, :^, :mod, :div, :rem, :widemul]
for f in (:+, :-, :abs, :abs2, :inv, :conj, :transpose, :adjoint, :angle)
@eval Base.$f(x::NeuralNumber) = x
end

for f in (:+, :-, :*, :/, :^, :mod, :div, :rem, :widemul)
@eval Base.$f(x::NeuralNumber, y::NeuralNumber) = max(x, y)
end

for f in [:+, :-, :*, :/, :^, :mod, :div, :rem, :widemul]
for f in (:+, :-, :*, :/, :^, :mod, :div, :rem, :widemul)
# specialize to avoid conflict with Base
#= @eval Base.$f(x::NeuralNumber, ::Bool) = x
@eval Base.$f(::Bool, y::NeuralNumber) = y =#
Expand Down

2 comments on commit 51f49c2

@rmsrosa
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/88065

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" 51f49c2964947927f8249f8af97089b8ef94d242
git push origin v0.1.3

Please sign in to comment.