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}, instead it has {actual}")]
31 IncorrectQuerySize { expected: usize, actual: usize },
32 #[error("the sum of the query and the start index must be at most {expected}")]
33 IncorrectStartIndex { expected: usize },
34 #[error("the zero padding start index must be at most {expected}")]
35 IncorrectStartIndexZeroPad { expected: usize },
36 #[error("the index of the nonzero block should be at most {expected}")]
37 IncorrectNonZeroIndex { expected: usize },
38 #[error("the nonzero scalar prefix should be at most {expected}")]
39 IncorrectNonzeroScalarPrefix { expected: usize },
40 #[error("Polynomial error: {0}")]
41 PolynomialError(Box<dyn std::error::Error + Send + Sync>),
42 #[error("MultilinearQuery is full, cannot update further. Has {max_query_vars} variables")]
43 MultilinearQueryFull { max_query_vars: usize },
44 #[error("argument length must be a power of two")]
45 PowerOfTwoLengthRequired,
46 #[error("argument {arg} must be in the range {range:?}")]
47 ArgumentRangeError { arg: String, range: Range<usize> },
48 #[error("logarithm of embedding degree of {log_embedding_degree} is too large.")]
49 LogEmbeddingDegreeTooLarge { log_embedding_degree: usize },
50 #[error("the polynomial is expected to have {expected} variables, and instead has {actual}")]
51 IncorrectNumberOfVariables { expected: usize, actual: usize },
52 #[error("indexed point on hypercube is out of range: index={index}")]
53 HypercubeIndexOutOfRange { index: usize },
54 #[error("the output polynomial must have size {expected}")]
55 IncorrectOutputPolynomialSize { expected: usize },
56 #[error(
57 "the total number of coefficients, {total_length}, in the piecewise multilinear is too large: {total_length} > 2^{total_n_vars}"
58 )]
59 PiecewiseMultilinearTooLong {
60 total_length: usize,
61 total_n_vars: usize,
62 },
63 #[error(
64 "there are a total of {actual} polynomials, according to n_pieces_by_vars, while you have provided evaluations for {expected}"
65 )]
66 PiecewiseMultilinearIncompatibleEvals { actual: usize, expected: usize },
67 #[error("cannot fold a constant multilinear")]
68 ConstantFold,
69 #[error("the function expects the expression to have degree at most 1")]
70 NonLinearExpression,
71}