use super::{DTypeSupport, convolve_impl};
use crate::algorithm::fft::FftAlgorithms;
use crate::algorithm::polynomial::helpers::{
validate_polynomial_coeffs, validate_polynomial_dtype,
};
use crate::dtype::DType;
use crate::error::{Error, Result};
use crate::ops::{BinaryOps, ComplexOps, IndexingOps, ReduceOps, ShapeOps, UtilityOps};
use crate::runtime::{Runtime, RuntimeClient};
use crate::tensor::Tensor;
pub fn polymul_impl<R, C>(
client: &C,
a: &Tensor<R>,
b: &Tensor<R>,
dtype_support: DTypeSupport,
) -> Result<Tensor<R>>
where
R: Runtime<DType = DType>,
C: RuntimeClient<R>
+ BinaryOps<R>
+ IndexingOps<R>
+ ShapeOps<R>
+ UtilityOps<R>
+ ReduceOps<R>
+ FftAlgorithms<R>
+ ComplexOps<R>,
{
validate_polynomial_dtype(a.dtype())?;
validate_polynomial_dtype(b.dtype())?;
dtype_support.check(a.dtype(), "polymul")?;
if a.dtype() != b.dtype() {
return Err(Error::DTypeMismatch {
lhs: a.dtype(),
rhs: b.dtype(),
});
}
validate_polynomial_coeffs(a.shape())?;
validate_polynomial_coeffs(b.shape())?;
convolve_impl(client, a, b, dtype_support)
}