1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2024 Ulvetanna Inc.

use crate::polynomial::{CompositionPoly, Error};
use binius_field::PackedField;
use binius_utils::bail;

#[derive(Debug, Copy, Clone)]
pub struct BivariateProduct;

impl BivariateProduct {
	pub const fn n_vars(&self) -> usize {
		2
	}

	pub const fn degree(&self) -> usize {
		2
	}
}

impl<P: PackedField> CompositionPoly<P> for BivariateProduct {
	fn n_vars(&self) -> usize {
		self.n_vars()
	}

	fn degree(&self) -> usize {
		self.degree()
	}

	fn evaluate(&self, query: &[P]) -> Result<P, Error> {
		if query.len() != 2 {
			bail!(Error::IncorrectQuerySize { expected: 2 });
		}
		Ok(query[0] * query[1])
	}

	fn binary_tower_level(&self) -> usize {
		0
	}
}