Skip to content

Commit

Permalink
first function
Browse files Browse the repository at this point in the history
  • Loading branch information
Devetak committed Jan 18, 2024
1 parent 7bcc070 commit cf38c13
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
name = "DiscoDiff"
uuid = "944e5dbc-7108-4f31-a215-df58b8009117"
authors = ["Mitja Devetak <[email protected]>"]
version = "0.1.0"


[deps]
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
14 changes: 14 additions & 0 deletions src/DiscoDiff.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
module DiscoDiff

export heaviside

function heaviside(x)
T = typeof(x)
return x > zero(T) ? one(T) : zero(T)
end








end
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using DiscoDiff, Test

@testset "heaviside function" begin
@test heaviside(2.0) == 1.0
@test heaviside(-2.0) == 0.0
end

0 comments on commit cf38c13

Please sign in to comment.