Skip to content
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

feat(math): implement (I)FFT #71

Merged
merged 29 commits into from
Oct 13, 2023
Merged

feat(math): implement (I)FFT #71

merged 29 commits into from
Oct 13, 2023

Conversation

fakedev9999
Copy link
Contributor

Description

  • This PR implements (I)FFT over dense univariate polynomial.

  • To do (I)FFT over a polynomial, an evaluation domain must exist, so this PR also implements evaluation domains. Evaluation domain is basically a domain over which finite field (I)FFTs can be performed.

  • GeneralEvaluationDomain is a wrapper over Radix2EvaluationDomain and MixedRadixEvaluationDomain where it generally tries to build a Radix2EvaluationDomain and falls back to a MixedRadixEvaluationDomain if the radix-2 multiplicative subgroup is too small.

  • Radix2EvaluationDomain is an EvaluationDomain for performing various kinds of polynomial arithmetic on top of fields that are FFT-friendly. Radix2EvaluationDomain supports (I)FFTs of size at most 2^two-adicity.

  • MixedRadixEvaluationDomain is an EvaluationDomain for performing various kinds of polynomial arithmetic on top of fields that are FFT-friendly but do not have high-enough two-adicity to perform the FFT efficiently. MixedRadixEvaluationDomain resolves this issue by using a larger subgroup obtained by combining G with another subgroup of size F::Config::kSmallSubgroupBase^F::Config::kSmallSubgroupAdicity, to obtain a subgroup generated by F::Config::kLargeSubgroupRootOfUnity.

@chokobole
Copy link
Contributor

I think fix(math): fix calculation of large subgroup root of unity is not a commit for bugfix.

@fakedev9999 fakedev9999 force-pushed the feat/implement-fft branch 2 times, most recently from f2428a9 to 9b3d8fb Compare October 4, 2023 04:59
@chokobole
Copy link
Contributor

chokobole commented Oct 4, 2023

Could you please separate file relocations from commit feat(math): introduce Radix2EvaluationDomain?

@chokobole
Copy link
Contributor

Plus, you forgot to update include guard macro.

@fakedev9999 fakedev9999 force-pushed the feat/implement-fft branch 2 times, most recently from 1c120af to 954eb49 Compare October 4, 2023 05:38
@chokobole
Copy link
Contributor

When seeing the commit body of feat(math): introduce bn384_small_two_adicity Fr, it needs to be tagged with test

@fakedev9999 fakedev9999 force-pushed the feat/implement-fft branch 4 times, most recently from 1b34765 to 064e820 Compare October 4, 2023 18:02
@chokobole chokobole force-pushed the feat/implement-fft branch 3 times, most recently from bb1c22a to 1e034f9 Compare October 5, 2023 16:18
@fakedev9999 fakedev9999 force-pushed the feat/implement-fft branch 2 times, most recently from 33e7f05 to 85ce232 Compare October 5, 2023 17:17
@chokobole chokobole force-pushed the feat/implement-fft branch 4 times, most recently from 3a756e2 to 129d947 Compare October 8, 2023 13:26
chokobole and others added 11 commits October 12, 2023 19:25
This gives a better performance if the type `T` meets some conditions
and can be implemented with fewer lines.

See https://google.github.io/styleguide/cppguide.html#noexcept
There are multiple definitions of `SparseCoefficients` in
`univaraite/sparse_coefficients.h` and
`multivariate/sparse_coefficients.h`. This prevents symbol conflict by
adding prefix `Multivariate` and `Univariate` respectively. In addition,
this renames followings in a similar way.

- `SparseUnivaraitePolynomial` -> `UnivariateSparsePolynomial`
- `DenseUnivariatePolynomial` -> `UnivariateDensePolynomial`
- `SparseMultivariatePolynomial` -> `MultivariateSparsePolynomial`
- `DenseCoefficients` -> `UnivariateDenseCoefficients`
This computes quotient and remainder for polynomial at once.
@fakedev9999
Copy link
Contributor Author

LGTM

Copy link
Contributor

@chokobole chokobole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

fakedev9999 and others added 8 commits October 13, 2023 16:02
To test `MixedRadixEvaluationDomain` we need a prime field such that
`MixedRadixEvaluationDomain` is constructable. Existing prime fields does not
fit to construct `MixedRadixEvaluationDomain`, so bn384_small_two_adicity is
added.
We have to use `omp_get_max_threads()` to adjust thread nums by
such environment variable `OMP_NUM_THREADS`.
See https://www.openmp.org/spec-html/5.0/openmpse50.html
Copy link
Contributor

@Insun35 Insun35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@dongchangYoo dongchangYoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fakedev9999 fakedev9999 merged commit 08e9872 into main Oct 13, 2023
3 checks passed
@fakedev9999 fakedev9999 deleted the feat/implement-fft branch October 13, 2023 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants