48SCENARIO(
"LagrangeInterpolation< int64_t > unit tests",
"[lagrange_interpolation]" )
52 typedef LInterp::Polynomial Polynomial;
54 GIVEN(
"A polynomial of degree 2 and 3 interpolation points" ) {
56 std::vector< Ring > X = { 1, 2, 3 };
57 std::vector< Ring > Y;
58 for (
auto x : X ) Y.push_back( P1( x ) );
61 THEN(
"Its Lagrange polynomial is itself" ) {
62 auto Lag1 = L1.polynomial( Y );
63 REQUIRE( Lag1 == P1 * L1.denominator() );
67 GIVEN(
"A polynomial of degree 3 and 4 interpolation points" ) {
69 std::vector< Ring > X = { -1, 1, 2, 3 };
70 std::vector< Ring > Y;
71 for (
auto x : X ) Y.push_back( P2( x ) );
74 THEN(
"Its Lagrange polynomial is itself" ) {
75 auto Lag2 = L2.polynomial( Y );
76 REQUIRE( Lag2 == P2 * L2.denominator() );
80 GIVEN(
"3 interpolation points (0,1), (1,3), (2,6)" ) {
81 std::vector< Ring > X = { 0, 1, 2 };
82 std::vector< Ring > Y = { 1, 3, 6 };
85 THEN(
"Its Lagrange polynomial is 1/2*(2+3x+x^2)" ) {
86 auto Lag3 = L3.polynomial( Y );
92 GIVEN(
"3 interpolation points (0,1), (1,7), (2,20)" ) {
93 std::vector< Ring > X = { 0, 1, 2 };
94 std::vector< Ring > Y = { 1, 7, 20 };
97 THEN(
"Its Lagrange polynomial is 1/2*(2+5x+7x^2)" ) {
98 auto Lag4 = L4.polynomial( Y );