Skip to content

Commit 0480a51

Browse files
committed
added ccall model
1 parent 24bda33 commit 0480a51

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

main.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ end
7676
# although it's hardly a big deal.
7777
@include_model "Base Julia features" "control_flow"
7878
@include_model "Base Julia features" "multithreaded"
79+
@include_model "Base Julia features" "call_C"
7980
@include_model "Core Turing syntax" "broadcast_macro"
8081
@include_model "Core Turing syntax" "dot_assume"
8182
@include_model "Core Turing syntax" "dot_observe"

models/call_C.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Get name of C standard library depending on the platform
2+
libc_name = Sys.iswindows() ? "msvcrt.dll" :
3+
Sys.isapple() ? "libc.dylib" :
4+
"libc.so.6"
5+
6+
@model function call_C(y)
7+
x ~ Normal(0, 1)
8+
9+
# Call C library abs function
10+
x_abs = @ccall libc_name.fabs(x::Cdouble)::Cdouble
11+
12+
y ~ Normal(0, x_abs)
13+
end
14+
15+
model = call_C()

0 commit comments

Comments
 (0)