1use std::ops::Range;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7 #[error("argument {arg} does not have expected length {expected}")]
8 IncorrectArgumentLength { arg: String, expected: usize },
9 #[error("the matrix is not square")]
10 MatrixNotSquare,
11 #[error("the matrix is singular")]
12 MatrixIsSingular,
13 #[error("domain size is larger than the field")]
14 DomainSizeTooLarge,
15 #[error("the inputted packed values slice had an unexpected length")]
16 InvalidPackedValuesLength,
17 #[error("remap index identifier not found in superset")]
18 RemapIdentifierNotFound,
19 #[error("duplicate point in domain")]
20 DuplicateDomainPoint,
21 #[error("expected the number of evaluations to match the domain size")]
22 ExtrapolateNumberOfEvaluations,
23 #[error("{0}")]
24 FieldError(#[from] binius_field::Error),
25 #[error(
26 "batch evaluation expects input slices to have the same length as the output slice;
27 expected length {expected}, got length {actual}"
28 )]
29 BatchEvaluateSizeMismatch { expected: usize, actual: usize },
30 #[error("the query must have size {expected}")]
31 IncorrectQuerySize { expected: usize },
32 #[error("the sum of the query and the start index must be at most {expected}")]
33 IncorrectStartIndex { expected: usize },
34 #[error("the nonzero scalar prefix should be at most {expected}")]
35 IncorrectNonzeroScalarPrefix { expected: usize },
36 #[error("Polynomial error: {0}")]
37 PolynomialError(Box<dyn std::error::Error + Send + Sync>),
38 #[error("MultilinearQuery is full, cannot update further. Has {max_query_vars} variables")]
39 MultilinearQueryFull { max_query_vars: usize },
40 #[error("argument length must be a power of two")]
41 PowerOfTwoLengthRequired,
42 #[error("argument {arg} must be in the range {range:?}")]
43 ArgumentRangeError { arg: String, range: Range<usize> },
44 #[error("logarithm of embedding degree of {log_embedding_degree} is too large.")]
45 LogEmbeddingDegreeTooLarge { log_embedding_degree: usize },
46 #[error("the polynomial is expected to have {expected} variables, and instead has {actual}")]
47 IncorrectNumberOfVariables { expected: usize, actual: usize },
48 #[error("indexed point on hypercube is out of range: index={index}")]
49 HypercubeIndexOutOfRange { index: usize },
50 #[error("the output polynomial must have size {expected}")]
51 IncorrectOutputPolynomialSize { expected: usize },
52 #[error("the total number of coefficients, {total_length}, in the piecewise multilinear is too large: {total_length} > 2^{total_n_vars}")]
53 PiecewiseMultilinearTooLong {
54 total_length: usize,
55 total_n_vars: usize,
56 },
57 #[error("there are a total of {actual} polynomials, according to n_pieces_by_vars, while you have provided evaluations for {expected}")]
58 PiecewiseMultilinearIncompatibleEvals { actual: usize, expected: usize },
59 #[error("cannot fold a constant multilinear")]
60 ConstantFold,
61 #[error("the function expects the expression to have degree at most 1")]
62 NonLinearExpression,
63}