-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(math): test
DFTBatch
and CosetLDEBatch
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 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
54 changes: 54 additions & 0 deletions
54
tachyon/math/polynomials/univariate/radix2_evaluation_domain_unittest.cc
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,54 @@ | ||
#include "tachyon/math/polynomials/univariate/radix2_evaluation_domain.h" | ||
|
||
#include <memory> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "tachyon/math/finite_fields/baby_bear/packed_baby_bear.h" | ||
#include "tachyon/math/finite_fields/koala_bear/packed_koala_bear.h" | ||
#include "tachyon/math/finite_fields/test/finite_field_test.h" | ||
#include "tachyon/math/matrix/matrix_types.h" | ||
#include "tachyon/math/polynomials/univariate/naive_batch_fft.h" | ||
|
||
namespace tachyon::math { | ||
|
||
namespace { | ||
|
||
template <typename F> | ||
class Radix2EvaluationDomainTest | ||
: public FiniteFieldTest< | ||
typename PackedPrimeFieldTraits<F>::PackedPrimeField> {}; | ||
|
||
} // namespace | ||
|
||
using RangeTypes = testing::Types<BabyBear, KoalaBear>; | ||
TYPED_TEST_SUITE(Radix2EvaluationDomainTest, RangeTypes); | ||
|
||
TYPED_TEST(Radix2EvaluationDomainTest, DFTBatch) { | ||
using F = TypeParam; | ||
for (size_t log_r = 0; log_r < 5; ++log_r) { | ||
RowMajorMatrix<F> expected = RowMajorMatrix<F>::Random(1 << log_r, 3); | ||
RowMajorMatrix<F> result = expected; | ||
NaiveBatchFFT<F>::DFTBatch(expected); | ||
std::unique_ptr<Radix2EvaluationDomain<F>> domain = | ||
Radix2EvaluationDomain<F>::Create(1 << log_r); | ||
domain->DFTBatch(result); | ||
EXPECT_EQ(expected, result); | ||
} | ||
} | ||
|
||
TYPED_TEST(Radix2EvaluationDomainTest, CosetLDEBatch) { | ||
using F = TypeParam; | ||
const F shift = F::FromMontgomery(F::Config::kSubgroupGenerator); | ||
for (size_t log_r = 0; log_r < 5; ++log_r) { | ||
RowMajorMatrix<F> expected = RowMajorMatrix<F>::Random(1 << log_r, 3); | ||
RowMajorMatrix<F> result = expected; | ||
NaiveBatchFFT<F>::CosetLDEBatch(expected, 1, shift); | ||
std::unique_ptr<Radix2EvaluationDomain<F>> domain = | ||
Radix2EvaluationDomain<F>::Create(1 << log_r); | ||
domain->CosetLDEBatch(result, 1, shift); | ||
EXPECT_EQ(expected, result); | ||
} | ||
} | ||
|
||
} // namespace tachyon::math |