@@ -2,7 +2,7 @@ use std::os::raw::c_char;
2
2
use std:: { collections:: HashMap , ffi:: CStr } ;
3
3
4
4
use crate :: repr:: DDNNFPtr ;
5
- use crate :: util:: semirings:: { RealSemiring , Semiring } ;
5
+ use crate :: util:: semirings:: { Complex , RealSemiring , Semiring } ;
6
6
use crate :: {
7
7
builder:: { bdd:: RobddBuilder , cache:: AllIteTable , BottomUpBuilder } ,
8
8
constants:: primes,
@@ -270,12 +270,27 @@ pub unsafe extern "C" fn bdd_wmc(
270
270
DDNNFPtr :: unsmoothed_wmc ( & ( * bdd) , & ( * wmc) ) . 0
271
271
}
272
272
273
+ #[ no_mangle]
274
+ #[ allow( clippy:: missing_safety_doc) ]
275
+ pub unsafe extern "C" fn bdd_wmc_complex (
276
+ bdd : * mut BddPtr < ' static > ,
277
+ wmc : * mut WmcParams < Complex > ,
278
+ ) -> Complex {
279
+ DDNNFPtr :: unsmoothed_wmc ( & ( * bdd) , & ( * wmc) )
280
+ }
281
+
273
282
#[ no_mangle]
274
283
#[ allow( clippy:: missing_safety_doc) ]
275
284
pub unsafe extern "C" fn new_wmc_params_f64 ( ) -> * mut WmcParams < RealSemiring > {
276
285
Box :: into_raw ( Box :: new ( WmcParams :: new ( HashMap :: from ( [ ] ) ) ) )
277
286
}
278
287
288
+ #[ no_mangle]
289
+ #[ allow( clippy:: missing_safety_doc) ]
290
+ pub unsafe extern "C" fn new_wmc_params_complex ( ) -> * mut WmcParams < Complex > {
291
+ Box :: into_raw ( Box :: new ( WmcParams :: new ( HashMap :: from ( [ ] ) ) ) )
292
+ }
293
+
279
294
#[ no_mangle]
280
295
#[ allow( clippy:: missing_safety_doc) ]
281
296
pub unsafe extern "C" fn wmc_param_f64_set_weight (
@@ -287,6 +302,17 @@ pub unsafe extern "C" fn wmc_param_f64_set_weight(
287
302
( * weights) . set_weight ( VarLabel :: new ( var) , RealSemiring ( low) , RealSemiring ( high) )
288
303
}
289
304
305
+ #[ no_mangle]
306
+ #[ allow( clippy:: missing_safety_doc) ]
307
+ pub unsafe extern "C" fn wmc_param_complex_set_weight (
308
+ weights : * mut WmcParams < Complex > ,
309
+ var : u64 ,
310
+ low : Complex ,
311
+ high : Complex ,
312
+ ) {
313
+ ( * weights) . set_weight ( VarLabel :: new ( var) , low, high)
314
+ }
315
+
290
316
#[ repr( C ) ]
291
317
#[ derive( Clone , Copy ) ]
292
318
pub struct WeightF64 ( pub f64 , pub f64 ) ;
@@ -312,3 +338,29 @@ pub unsafe extern "C" fn weight_f64_lo(w: WeightF64) -> f64 {
312
338
pub unsafe extern "C" fn weight_f64_hi ( w : WeightF64 ) -> f64 {
313
339
w. 1
314
340
}
341
+
342
+ #[ repr( C ) ]
343
+ #[ derive( Clone , Copy ) ]
344
+ pub struct WeightComplex ( pub Complex , pub Complex ) ;
345
+
346
+ #[ no_mangle]
347
+ #[ allow( clippy:: missing_safety_doc) ]
348
+ pub unsafe extern "C" fn wmc_param_complex_var_weight (
349
+ weights : * mut WmcParams < Complex > ,
350
+ var : u64 ,
351
+ ) -> WeightComplex {
352
+ let ( l, h) = ( * weights) . var_weight ( VarLabel :: new ( var) ) ;
353
+ WeightComplex ( * l, * h)
354
+ }
355
+
356
+ #[ no_mangle]
357
+ #[ allow( clippy:: missing_safety_doc) ]
358
+ pub unsafe extern "C" fn weight_complex_lo ( w : WeightComplex ) -> Complex {
359
+ w. 0
360
+ }
361
+
362
+ #[ no_mangle]
363
+ #[ allow( clippy:: missing_safety_doc) ]
364
+ pub unsafe extern "C" fn weight_complex_hi ( w : WeightComplex ) -> Complex {
365
+ w. 1
366
+ }
0 commit comments