Skip to content

Commit 9c012f4

Browse files
committed
add delete bins to capi.
1 parent 65eb260 commit 9c012f4

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

pineappl_capi/src/lib.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ pub unsafe extern "C" fn pineappl_grid_read(filename: *const c_char) -> Box<Grid
847847
///
848848
/// # Safety
849849
///
850-
/// The parameter `grid` must be valid `Grid` object created by either `pineappl_grid_new` or
850+
/// The `grid` must be valid `Grid` object created by either `pineappl_grid_new` or
851851
/// `pineappl_grid_read`.
852852
///
853853
/// # Panics
@@ -860,6 +860,27 @@ pub unsafe extern "C" fn pineappl_grid_merge_bins(grid: *mut Grid, from: usize,
860860
grid.merge_bins(from..to).unwrap();
861861
}
862862

863+
/// Deletes bins with the corresponding `bin_indices`. Repeated indices and indices larger or
864+
/// equal the bin length are ignored.
865+
///
866+
/// # Safety
867+
///
868+
/// The parameter `grid` must be valid `Grid` object created by either `pineappl_grid_new` or
869+
/// `pineappl_grid_read`.
870+
///
871+
/// # Panics
872+
///
873+
/// TODO
874+
#[no_mangle]
875+
pub unsafe extern "C" fn pineappl_grid_delete_bins(grid: *mut Grid,
876+
bin_indices_ptr: *const usize,
877+
bin_indices_len: usize) {
878+
let grid = unsafe { &mut *grid };
879+
let bin_indices = unsafe { std::slice::from_raw_parts(bin_indices_ptr, bin_indices_len) };
880+
grid.delete_bins(bin_indices);
881+
882+
}
883+
863884
/// Merges `other` into `grid` and subsequently deletes `other`.
864885
///
865886
/// # Safety

0 commit comments

Comments
 (0)