summaryrefslogtreecommitdiff
path: root/src/runtime/c
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2016-05-30 11:25:59 +0000
committerkrasimir <krasimir@chalmers.se>2016-05-30 11:25:59 +0000
commit3381ae1aa009fd26455639bf4affb262414ab40e (patch)
tree12a398185c150439dc871706a18969d26e1c746a /src/runtime/c
parenta00532d5e4c4ae09b5d5f491656c04f0e60fa62d (diff)
added getFunctionProb in the Java and C API
Diffstat (limited to 'src/runtime/c')
-rw-r--r--src/runtime/c/pgf/pgf.c11
-rw-r--r--src/runtime/c/pgf/pgf.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime/c/pgf/pgf.c b/src/runtime/c/pgf/pgf.c
index 0070e5f48..370b9411b 100644
--- a/src/runtime/c/pgf/pgf.c
+++ b/src/runtime/c/pgf/pgf.c
@@ -165,6 +165,17 @@ pgf_function_type(PgfPGF* pgf, PgfCId funname)
return absfun->type;
}
+double
+pgf_function_prob(PgfPGF* pgf, PgfCId funname)
+{
+ PgfAbsFun* absfun =
+ gu_seq_binsearch(pgf->abstract.funs, pgf_absfun_order, PgfAbsFun, funname);
+ if (absfun == NULL)
+ return INFINITY;
+
+ return absfun->ep.prob;
+}
+
GuString
pgf_print_name(PgfConcr* concr, PgfCId id)
{
diff --git a/src/runtime/c/pgf/pgf.h b/src/runtime/c/pgf/pgf.h
index 4a6199c6f..365d20d73 100644
--- a/src/runtime/c/pgf/pgf.h
+++ b/src/runtime/c/pgf/pgf.h
@@ -66,6 +66,9 @@ pgf_iter_functions_by_cat(PgfPGF* pgf, PgfCId catname,
PgfType*
pgf_function_type(PgfPGF* pgf, PgfCId funname);
+double
+pgf_function_prob(PgfPGF* pgf, PgfCId funname);
+
GuString
pgf_print_name(PgfConcr*, PgfCId id);