-
Notifications
You must be signed in to change notification settings - Fork 400
Add data structures for multilinear extensions #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 44 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
2351c4e
add multilinear trait
tsunrise 68a5b33
add dense multilinear poly structure
tsunrise 4d81c31
tweaks
tsunrise e54ff27
Merge branch 'master' into multilinear
tsunrise 77a5cfd
add interfaces for multilinear poly
tsunrise ec753d9
add evaluate & relabel for multilinear
tsunrise bd8c8fb
Merge branch 'master' of https://github.com/arkworks-rs/algebra into …
tsunrise e330ead
tweaks
tsunrise adcb68c
temporarily rely on ark-std in "rand" branch
tsunrise ac68907
add unit tests for arithmetic
tsunrise 72776d7
Merge branch 'master' into multilinear
tsunrise a652356
add support for serialization
tsunrise 51ac893
tweak
tsunrise cec05f1
add sparse multilinear polynomial, add evaluation method
tsunrise 3a424ec
impl sparse polynomial arithmetic
tsunrise 2a7f80c
add relabel feature for sparse multilinear poly
tsunrise fe558db
Merge branch 'master' into multilinear
tsunrise 65ae89c
tweaks
tsunrise 14527c4
update changelog
tsunrise 2a148a2
update changelog (add pending section)
tsunrise a2bab48
change wording to avoid confusion
tsunrise 74c61bf
add Index
tsunrise 2c1ec95
Merge branch 'master' into multilinear
tsunrise e6ce297
Merge branch 'master' into multilinear
tsunrise 52cb95d
put sparse multilinear public, add benchmark
tsunrise 5f68180
add IntoIter for multilinear polynomials
tsunrise 54dda76
tweak benchmarks
tsunrise 6a0318d
change CHANGELOG.md
tsunrise e7954b1
some tweaks on comments and remove unused import
tsunrise 2b0387f
update README.md
tsunrise afa1b5f
update ark-poly/README.md
tsunrise c8fa76b
tweak README.md
tsunrise ba0bd0c
rename `partial_evaluate` to `fix_variables`
tsunrise dd8707e
move multilinear extension to evaluations module
tsunrise 3e6dd90
tweak benchmarks
tsunrise 916a95f
run fmt
tsunrise cbf099a
update CHANGELOG.md
tsunrise 7de1ae9
change API described in README.md
tsunrise 18eb780
Merge branch 'master' into multilinear
tsunrise a1ed89b
tweak some apis
tsunrise 5054bb4
add api for ml
tsunrise e075040
Merge branch 'master' into multilinear
tsunrise 6ef9c17
bug fix
tsunrise 366749f
bug fix (trivial sparse poly)
tsunrise 4b8cda8
change API of `evaluate`, tweak some documentations
tsunrise c237053
tweak benchmark
tsunrise 4b4eb8d
Merge branch 'master' into multilinear
tsunrise e8f52ed
undo "Rename `Evaluations` to `UVEvaluations` "
tsunrise 5f8a4fa
run cargo fmt
tsunrise 3dee101
change README.md
tsunrise 89c19a2
small tweaks on `index`
tsunrise 2190738
Merge branch 'master' into multilinear
tsunrise 5ce208c
tweak documentations
tsunrise 0d65000
tweak README (a small change on links)
tsunrise File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,56 @@ | ||
| #[macro_use] | ||
| extern crate criterion; | ||
|
|
||
| use ark_ff::Field; | ||
| use ark_poly::{DenseMultilinearExtension, MultilinearExtension}; | ||
| use ark_std::ops::Range; | ||
| use ark_std::test_rng; | ||
| use ark_test_curves::bls12_381; | ||
| use criterion::{black_box, BenchmarkId, Criterion}; | ||
|
|
||
| const NUM_VARIABLES_RANGE: Range<usize> = 10..21; | ||
|
|
||
| fn arithmetic_op_bench<F: Field>(c: &mut Criterion) { | ||
| let mut rng = test_rng(); | ||
|
|
||
| let mut group = c.benchmark_group("Add"); | ||
| for nv in NUM_VARIABLES_RANGE { | ||
| group.bench_with_input(BenchmarkId::new("Add", nv), &nv, |b, &nv| { | ||
| let poly1 = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng); | ||
| let poly2 = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng); | ||
| b.iter(|| black_box(&poly1 + &poly2)) | ||
| }); | ||
| } | ||
| group.finish(); | ||
|
|
||
| let mut group = c.benchmark_group("Sub"); | ||
| for nv in NUM_VARIABLES_RANGE { | ||
| group.bench_with_input(BenchmarkId::new("Sub", nv), &nv, |b, &nv| { | ||
| let poly1 = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng); | ||
| let poly2 = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng); | ||
| b.iter(|| black_box(&poly1 - &poly2)) | ||
| }); | ||
| } | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn evaluation_op_bench<F: Field>(c: &mut Criterion) { | ||
| let mut rng = test_rng(); | ||
| let mut group = c.benchmark_group("Evaluate"); | ||
| for nv in NUM_VARIABLES_RANGE { | ||
| group.bench_with_input(BenchmarkId::new("evaluate", nv), &nv, |b, &nv| { | ||
| let poly = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng); | ||
| let point: Vec<_> = (0..nv).map(|_| F::rand(&mut rng)).collect(); | ||
| b.iter(|| black_box(poly.evaluate(&point))) | ||
| }); | ||
| } | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn bench_bls_381(c: &mut Criterion) { | ||
| arithmetic_op_bench::<bls12_381::Fr>(c); | ||
| evaluation_op_bench::<bls12_381::Fr>(c); | ||
| } | ||
|
|
||
| criterion_group!(benches, bench_bls_381); | ||
| criterion_main!(benches); |
File renamed without changes.
This file contains hidden or 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,91 @@ | ||
| #[macro_use] | ||
| extern crate criterion; | ||
|
|
||
| use ark_ff::Field; | ||
| use ark_poly::{MultilinearExtension, SparseMultilinearExtension}; | ||
| use ark_std::ops::Range; | ||
| use ark_std::test_rng; | ||
| use ark_test_curves::bls12_381; | ||
| use criterion::{black_box, BenchmarkId, Criterion}; | ||
|
|
||
| const NUM_VARIABLES_RANGE: Range<usize> = 12..23; | ||
|
|
||
| fn arithmetic_op_bench<F: Field>(c: &mut Criterion) { | ||
| let mut rng = test_rng(); | ||
|
|
||
| let mut group = c.benchmark_group("Add"); | ||
| for nv in NUM_VARIABLES_RANGE { | ||
| let num_nonzero_entries = 1 << (nv / 2); | ||
| group.bench_with_input( | ||
| BenchmarkId::new("add", num_nonzero_entries), | ||
| &num_nonzero_entries, | ||
| |b, &num_nonzero_entries| { | ||
| let poly1 = SparseMultilinearExtension::<F>::rand_with_config( | ||
| nv, | ||
| num_nonzero_entries, | ||
| &mut rng, | ||
| ); | ||
| let poly2 = SparseMultilinearExtension::<F>::rand_with_config( | ||
| nv, | ||
| num_nonzero_entries, | ||
| &mut rng, | ||
| ); | ||
| b.iter(|| black_box(&poly1 + &poly2)) | ||
| }, | ||
| ); | ||
| } | ||
| group.finish(); | ||
|
|
||
| let mut group = c.benchmark_group("Sub"); | ||
| for nv in NUM_VARIABLES_RANGE { | ||
| let num_nonzero_entries = 1 << (nv / 2); | ||
| group.bench_with_input( | ||
| BenchmarkId::new("sub", num_nonzero_entries), | ||
| &num_nonzero_entries, | ||
| |b, &num_nonzero_entries| { | ||
| let poly1 = SparseMultilinearExtension::<F>::rand_with_config( | ||
| nv, | ||
| num_nonzero_entries, | ||
| &mut rng, | ||
| ); | ||
| let poly2 = SparseMultilinearExtension::<F>::rand_with_config( | ||
| nv, | ||
| num_nonzero_entries, | ||
| &mut rng, | ||
| ); | ||
| b.iter(|| black_box(&poly1 - &poly2)) | ||
| }, | ||
| ); | ||
| } | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn evaluation_op_bench<F: Field>(c: &mut Criterion) { | ||
| let mut rng = test_rng(); | ||
| let mut group = c.benchmark_group("Evaluate"); | ||
| for nv in NUM_VARIABLES_RANGE { | ||
| let num_nonzero_entries = 1 << (nv / 2); | ||
| group.bench_with_input( | ||
| BenchmarkId::new("evaluate", num_nonzero_entries), | ||
| &num_nonzero_entries, | ||
| |b, &num_nonzero_entries| { | ||
| let poly = SparseMultilinearExtension::<F>::rand_with_config( | ||
| nv, | ||
| num_nonzero_entries, | ||
| &mut rng, | ||
| ); | ||
| let point: Vec<_> = (0..nv).map(|_| F::rand(&mut rng)).collect(); | ||
| b.iter(|| black_box(poly.evaluate(&point))) | ||
| }, | ||
| ); | ||
| } | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn bench_bls381(c: &mut Criterion) { | ||
| arithmetic_op_bench::<bls12_381::Fr>(c); | ||
| evaluation_op_bench::<bls12_381::Fr>(c); | ||
| } | ||
|
|
||
| criterion_group!(benches, bench_bls381); | ||
| criterion_main!(benches); |
This file contains hidden or 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 hidden or 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 hidden or 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,2 @@ | ||
| pub mod multivariate; | ||
| pub mod univariate; |
This file contains hidden or 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,4 @@ | ||
| pub mod multilinear; | ||
| pub use multilinear::{ | ||
| DenseMultilinearExtension, MultilinearExtension, SparseMultilinearExtension, | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.