Skip to main content

polars_compute/
lib.rs

1#![cfg_attr(feature = "simd", feature(portable_simd))]
2
3use arrow::types::NativeType;
4
5pub mod arithmetic;
6pub mod arity;
7pub mod binview_index_map;
8pub mod bitwise;
9pub mod boolean;
10#[cfg(feature = "approx_unique")]
11pub mod cardinality;
12#[cfg(feature = "cast")]
13pub mod cast;
14pub mod comparisons;
15#[cfg(feature = "dtype-decimal")]
16pub mod decimal;
17pub mod ewm;
18pub mod filter;
19#[cfg(feature = "cast")]
20pub mod find_validity_mismatch;
21pub mod float_sum;
22#[cfg(feature = "gather")]
23pub mod gather;
24pub mod horizontal_flatten;
25#[cfg(feature = "approx_unique")]
26pub mod hyperloglogplus;
27pub mod if_then_else;
28pub mod min_max;
29pub mod moment;
30pub mod nan;
31pub mod propagate_dictionary;
32pub mod propagate_nulls;
33pub mod rolling;
34pub mod size;
35pub mod sum;
36pub mod trim_lists_to_normalized_offsets;
37pub mod unique;
38
39// Trait to enable the scalar blanket implementation.
40pub trait NotSimdPrimitive: NativeType {}
41
42#[cfg(not(feature = "simd"))]
43impl<T: NativeType> NotSimdPrimitive for T {}
44
45#[cfg(feature = "simd")]
46impl NotSimdPrimitive for u128 {}
47#[cfg(feature = "simd")]
48impl NotSimdPrimitive for i128 {}
49#[cfg(feature = "simd")]
50impl NotSimdPrimitive for pf16 {}
51
52// Trait to allow blanket impl for all SIMD types when simd is enabled.
53#[cfg(feature = "simd")]
54mod _simd_primitive {
55    use std::simd::SimdElement;
56    pub trait SimdPrimitive: SimdElement {}
57    impl SimdPrimitive for u8 {}
58    impl SimdPrimitive for u16 {}
59    impl SimdPrimitive for u32 {}
60    impl SimdPrimitive for u64 {}
61    impl SimdPrimitive for usize {}
62    impl SimdPrimitive for i8 {}
63    impl SimdPrimitive for i16 {}
64    impl SimdPrimitive for i32 {}
65    impl SimdPrimitive for i64 {}
66    impl SimdPrimitive for isize {}
67    impl SimdPrimitive for f32 {}
68    impl SimdPrimitive for f64 {}
69}
70
71#[cfg(feature = "simd")]
72pub use _simd_primitive::SimdPrimitive;
73#[cfg(feature = "simd")]
74use polars_utils::float16::pf16;