Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove powf_scalar kernel #4187

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions arrow-arith/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use arrow_array::*;
use arrow_buffer::i256;
use arrow_buffer::ArrowNativeType;
use arrow_schema::*;
use num::traits::Pow;
use std::cmp::min;
use std::sync::Arc;

Expand Down Expand Up @@ -1342,18 +1341,6 @@ pub fn negate_checked<T: ArrowNumericType>(
try_unary(array, |value| value.neg_checked())
}

/// Raise array with floating point values to the power of a scalar.
pub fn powf_scalar<T>(
array: &PrimitiveArray<T>,
raise: T::Native,
) -> Result<PrimitiveArray<T>, ArrowError>
where
T: ArrowFloatNumericType,
T::Native: Pow<T::Native, Output = T::Native>,
{
Ok(unary(array, |x| x.pow(raise)))
}

/// Perform `left * right` operation on two arrays. If either left or right value is null
/// then the result is also null.
///
Expand Down Expand Up @@ -3217,18 +3204,6 @@ mod tests {
assert_eq!(expected, actual);
}

#[test]
fn test_primitive_array_raise_power_scalar() {
let a = Float64Array::from(vec![1.0, 2.0, 3.0]);
let actual = powf_scalar(&a, 2.0).unwrap();
let expected = Float64Array::from(vec![1.0, 4.0, 9.0]);
assert_eq!(expected, actual);
let a = Float64Array::from(vec![Some(1.0), None, Some(3.0)]);
let actual = powf_scalar(&a, 2.0).unwrap();
let expected = Float64Array::from(vec![Some(1.0), None, Some(9.0)]);
assert_eq!(expected, actual);
}

#[test]
fn test_primitive_add_wrapping_overflow() {
let a = Int32Array::from(vec![i32::MAX, i32::MIN]);
Expand Down
29 changes: 0 additions & 29 deletions arrow-array/src/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,35 +558,6 @@ impl ArrowNumericType for Decimal256Type {
}
}

/// A subtype of primitive type that represents numeric float values
#[cfg(feature = "simd")]
pub trait ArrowFloatNumericType: ArrowNumericType {
/// SIMD version of pow
fn pow(base: Self::Simd, raise: Self::Simd) -> Self::Simd;
}

/// A subtype of primitive type that represents numeric float values
#[cfg(not(feature = "simd"))]
pub trait ArrowFloatNumericType: ArrowNumericType {}

macro_rules! make_float_numeric_type {
($impl_ty:ty, $simd_ty:ident) => {
#[cfg(feature = "simd")]
impl ArrowFloatNumericType for $impl_ty {
#[inline]
fn pow(base: Self::Simd, raise: Self::Simd) -> Self::Simd {
base.powf(raise)
}
}

#[cfg(not(feature = "simd"))]
impl ArrowFloatNumericType for $impl_ty {}
};
}

make_float_numeric_type!(Float32Type, f32x16);
make_float_numeric_type!(Float64Type, f64x8);

#[cfg(all(test, feature = "simd"))]
mod tests {
use super::*;
Expand Down
4 changes: 1 addition & 3 deletions arrow/src/datatypes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
//! * [`DataType`](crate::datatypes::DataType) to describe the type of a field.

pub use arrow_array::types::*;
pub use arrow_array::{
ArrowFloatNumericType, ArrowNativeTypeOp, ArrowNumericType, ArrowPrimitiveType,
};
pub use arrow_array::{ArrowNativeTypeOp, ArrowNumericType, ArrowPrimitiveType};
pub use arrow_buffer::{i256, ArrowNativeType, ToByteSlice};
pub use arrow_data::decimal::*;
pub use arrow_schema::{
Expand Down