comparison crp.pl @ 3:974d7be8eec4 tip

Update to pack-based dcg utilities
author samer
date Tue, 03 Oct 2017 11:52:23 +0100
parents 2c8a10d9e3cb
children
comparison
equal deleted inserted replaced
2:2c8a10d9e3cb 3:974d7be8eec4
32 32
33 */ 33 */
34 :- meta_predicate seqmap_classes(4,+,?,?). 34 :- meta_predicate seqmap_classes(4,+,?,?).
35 35
36 :- use_foreign_library(foreign(crp)). 36 :- use_foreign_library(foreign(crp)).
37 :- use_module(library(dcgu)). 37 :- use_module(library(dcg_core)).
38 :- use_module(library(dcg_pair)).
39 :- use_module(library(dcg_macros)).
38 :- use_module(library(math)). 40 :- use_module(library(math)).
39 :- use_module(library(eval)). 41 :- use_module(library(eval)).
40 :- use_module(library(lazy)). 42 :- use_module(library(lazy)).
41 :- use_module(library(randpred)). 43 :- use_module(library(randpred)).
42 :- use_module(library(apply_macros)). 44 :- use_module(library(apply_macros)).
168 %------------------------------------------------------------------ 170 %------------------------------------------------------------------
169 % Get posterior distribution at node using stick-breaking 171 % Get posterior distribution at node using stick-breaking
170 % construction. 172 % construction.
171 173
172 lazy_dp(A,H,P0,Vals,Probs) --> 174 lazy_dp(A,H,P0,Vals,Probs) -->
173 spawn(S0), { lazy_unfold(unfold_dp(A,H),Vals,Probs,(P0,S0),_) }. 175 spawn(S0), { lazy_unfold(unfold_dp(A,H),Vals,Probs,P0-S0,_) }.
174 176
175 lazy_dp_paired(A,H,P0,ValsProbs) --> 177 lazy_dp_paired(A,H,P0,ValsProbs) -->
176 spawn(S0), { lazy_unfold(unfold_dp(A,H),ValsProbs,(P0,S0),_) }. 178 spawn(S0), { lazy_unfold(unfold_dp(A,H),ValsProbs,P0-S0,_) }.
177 179
178 unfold_dp(A,H,V,X) --> \> call(H,V), unfold_gem(A,X). 180 unfold_dp(A,H,V,X) --> \> call(H,V), unfold_gem(A,X).
179 unfold_dp(A,H,V:X) --> \> call(H,V), unfold_gem(A,X). 181 unfold_dp(A,H,V:X) --> \> call(H,V), unfold_gem(A,X).
180 182
181 % lazy_gem(A,Probs) --> spawn(S0), { lazy_unfold(unfold_gem(A),Probs,(1,S0),_) }. 183 % lazy_gem(A,Probs) --> spawn(S0), { lazy_unfold(unfold_gem(A),Probs,(1,S0),_) }.