-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
256 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ mod from_span; | |
mod horner_eval; | ||
mod to_array; | ||
mod math; | ||
mod array_print; | ||
|
||
#[cfg(test)] | ||
mod tests; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use core::debug::PrintTrait; | ||
|
||
impl ArrayPrintTrait<T, +PrintTrait<T>, +Drop<T>, +Copy<T>> of PrintTrait<Array<T>> { | ||
fn print(self: Array<T>) { | ||
let span = self.span(); | ||
let mut i = 0; | ||
loop { | ||
if i == span.len() { | ||
break; | ||
}; | ||
(*span[i]).print(); | ||
i += 1; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,54 @@ | ||
use core::array::ArrayTrait; | ||
use cairo_verifier::channel::channel::ChannelSentFelt; | ||
use cairo_verifier::common::horner_eval::horner_eval; | ||
|
||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_horner_eval_0() { | ||
let mut coefs = ArrayTrait::<ChannelSentFelt>::new(); | ||
let mut coefs = ArrayTrait::<felt252>::new(); | ||
let eval = horner_eval(coefs.span(), 1); | ||
assert(eval == 0, 'invalid evaluation result'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_horner_eval_1() { | ||
let mut coefs = ArrayTrait::<ChannelSentFelt>::new(); | ||
coefs.append(ChannelSentFelt { value: 1 }); | ||
let mut coefs = ArrayTrait::<felt252>::new(); | ||
coefs.append(1); | ||
let eval = horner_eval(coefs.span(), 7); | ||
assert(eval == 1, 'invalid evaluation result'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_horner_eval_2() { | ||
let mut coefs = ArrayTrait::<ChannelSentFelt>::new(); | ||
coefs.append(ChannelSentFelt { value: 4 }); | ||
coefs.append(ChannelSentFelt { value: 10 }); | ||
coefs.append(ChannelSentFelt { value: 19 }); | ||
coefs.append(ChannelSentFelt { value: 1 }); | ||
coefs.append(ChannelSentFelt { value: 9 }); | ||
let mut coefs = ArrayTrait::<felt252>::new(); | ||
coefs.append(4); | ||
coefs.append(10); | ||
coefs.append(19); | ||
coefs.append(1); | ||
coefs.append(9); | ||
let eval = horner_eval(coefs.span(), 13); | ||
assert(eval == 262591, 'invalid evaluation result'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_horner_eval_3() { | ||
let mut coefs = ArrayTrait::<ChannelSentFelt>::new(); | ||
coefs.append(ChannelSentFelt { value: 4 }); | ||
coefs.append(ChannelSentFelt { value: 10 }); | ||
coefs.append(ChannelSentFelt { value: 19 }); | ||
coefs.append(ChannelSentFelt { value: 1 }); | ||
coefs.append(ChannelSentFelt { value: 9 }); | ||
coefs.append(ChannelSentFelt { value: 99 }); | ||
coefs.append(ChannelSentFelt { value: 1 }); | ||
coefs.append(ChannelSentFelt { value: 7 }); | ||
coefs.append(ChannelSentFelt { value: 13 }); | ||
coefs.append(ChannelSentFelt { value: 2 }); | ||
coefs.append(ChannelSentFelt { value: 5 }); | ||
coefs.append(ChannelSentFelt { value: 7 }); | ||
coefs.append(ChannelSentFelt { value: 111 }); | ||
coefs.append(ChannelSentFelt { value: 1 }); | ||
let mut coefs = ArrayTrait::<felt252>::new(); | ||
coefs.append(4); | ||
coefs.append(10); | ||
coefs.append(19); | ||
coefs.append(1); | ||
coefs.append(9); | ||
coefs.append(99); | ||
coefs.append(1); | ||
coefs.append(7); | ||
coefs.append(13); | ||
coefs.append(2); | ||
coefs.append(5); | ||
coefs.append(7); | ||
coefs.append(111); | ||
coefs.append(1); | ||
let eval = horner_eval(coefs.span(), 19); | ||
assert(eval == 288577899334361215, 'invalid evaluation result'); | ||
} |
Oops, something went wrong.