mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 16:23:12 +00:00
more fixes
This commit is contained in:
parent
3e00a5819f
commit
b17dabefeb
@ -15,6 +15,7 @@ pub fn test_inputs(modulus: BigUint, word_bits: usize) -> Vec<BigUint> {
|
|||||||
let smalls: Vec<_> = (0..BIGGEST_SMALL).map(BigUint::from).collect();
|
let smalls: Vec<_> = (0..BIGGEST_SMALL).map(BigUint::from).collect();
|
||||||
// ... and close to MAX: MAX - x
|
// ... and close to MAX: MAX - x
|
||||||
let word_max = (BigUint::from(1u32) << word_bits) - 1u32;
|
let word_max = (BigUint::from(1u32) << word_bits) - 1u32;
|
||||||
|
let multiple_words_max = (BigUint::from(1u32) << modwords * word_bits) - 1u32;
|
||||||
let bigs = smalls.iter().map(|x| &word_max - x).collect();
|
let bigs = smalls.iter().map(|x| &word_max - x).collect();
|
||||||
let one_words = [smalls, bigs].concat();
|
let one_words = [smalls, bigs].concat();
|
||||||
// For each of the one word inputs above, create a new one at word i.
|
// For each of the one word inputs above, create a new one at word i.
|
||||||
@ -34,7 +35,7 @@ pub fn test_inputs(modulus: BigUint, word_bits: usize) -> Vec<BigUint> {
|
|||||||
let diff_max = basic_inputs
|
let diff_max = basic_inputs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.clone())
|
.map(|x| x.clone())
|
||||||
.map(|x| word_max.clone() - x)
|
.map(|x| multiple_words_max.clone() - x)
|
||||||
.filter(|x| x < &modulus)
|
.filter(|x| x < &modulus)
|
||||||
.collect();
|
.collect();
|
||||||
// Inputs 'difference from' modulus value
|
// Inputs 'difference from' modulus value
|
||||||
@ -175,10 +176,16 @@ macro_rules! test_arithmetic {
|
|||||||
fn arithmetic_subtraction() {
|
fn arithmetic_subtraction() {
|
||||||
let modulus = <$field>::order();
|
let modulus = <$field>::order();
|
||||||
crate::field::field_testing::run_binaryop_test_cases(
|
crate::field::field_testing::run_binaryop_test_cases(
|
||||||
modulus,
|
modulus.clone(),
|
||||||
WORD_BITS,
|
WORD_BITS,
|
||||||
<$field>::sub,
|
<$field>::sub,
|
||||||
BigUint::sub,
|
|x, y| {
|
||||||
|
if x >= y {
|
||||||
|
x.clone() - y.clone()
|
||||||
|
} else {
|
||||||
|
modulus.clone() - y.clone() + x
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,10 +193,16 @@ macro_rules! test_arithmetic {
|
|||||||
fn arithmetic_negation() {
|
fn arithmetic_negation() {
|
||||||
let modulus = <$field>::order();
|
let modulus = <$field>::order();
|
||||||
crate::field::field_testing::run_unaryop_test_cases(
|
crate::field::field_testing::run_unaryop_test_cases(
|
||||||
modulus,
|
modulus.clone(),
|
||||||
WORD_BITS,
|
WORD_BITS,
|
||||||
<$field>::neg,
|
<$field>::neg,
|
||||||
BigUint::neg,
|
|x| {
|
||||||
|
if x == BigUint::from(0u32) {
|
||||||
|
BigUint::from(0u32)
|
||||||
|
} else {
|
||||||
|
modulus.clone() - x.clone()
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user