Skip to content

Commit

Permalink
[util.series] allow series_uncorrelated_deviation/series
Browse files Browse the repository at this point in the history
  • Loading branch information
spj101 committed Mar 1, 2018
1 parent eb3ddc1 commit e2aaa38
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion util/secdecutil/series.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ namespace secdecutil {
// nested if statements drop terms that have a multiplicative
// zero.
std::vector<Tout> content;
Tout denominator( s2_content.at(0) );
T2 denominator( s2_content.at(0) );
content.reserve(order_max-order_min+1);
Tout tmp( s1_content.at(0)/ s2_content.at(0) );
bool tmp_initialized;
Expand Down
39 changes: 39 additions & 0 deletions util/tests/test_series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <type_traits>

#include "../secdecutil/integrand_container.hpp"
#include "../secdecutil/uncertainties.hpp"

// Helper struct to check is an iterator is a const_iterator
template<typename Iterator>
Expand Down Expand Up @@ -626,6 +627,9 @@ TEST_CASE( "Operator /" , "[Series]" ) {
auto truncated_one = secdecutil::Series<int>(0,1,{1,0 },true );
auto truncated_one_more_terms = secdecutil::Series<int>(0,3,{1,0,0,0},true );
auto exact_one = secdecutil::Series<int>(0,0,{1 },false);

auto series_uncorrelated_deviation = secdecutil::Series<secdecutil::UncorrelatedDeviation<int>>( 4, 5,{ {1,3}, {1,4}},false);
auto uncorrelated_deviation_one = secdecutil::Series<secdecutil::UncorrelatedDeviation<int>>( 0, 1,{ {1,3}, {0,5}},false);

SECTION ( " series / scalar " ) {
REQUIRE( (two_times_series / 2) == series );
Expand All @@ -650,6 +654,41 @@ TEST_CASE( "Operator /" , "[Series]" ) {
REQUIRE( ( series /= series ) == truncated_one );
REQUIRE( series == truncated_one ); // after application of "/="
};

SECTION ( " series_uncorrelated_deviation / series " ) {

// Note: Can not compare two uncertain series for equality
// Implement by hand:
// REQUIRE( ( series_uncorrelated_deviation / series ) == uncorrelated_deviation_one );
auto ratio = series_uncorrelated_deviation / series;
auto s1 = ratio;
auto s2 = uncorrelated_deviation_one;
REQUIRE ( s1.expansion_parameter == s2.expansion_parameter );
REQUIRE ( s1.get_order_min() == s2.get_order_min() );
REQUIRE ( s1.get_order_max() == s2.get_order_max() );
REQUIRE ( s1.get_truncated_above() != s2.get_truncated_above() );
for ( size_t idx = 0 ; idx < s1.get_order_max()-s1.get_order_min()+1 ; ++idx )
{
REQUIRE ( s1.get_content().at(idx).value == s2.get_content().at(idx).value ); // Compare value
REQUIRE ( s1.get_content().at(idx).uncertainty == s2.get_content().at(idx).uncertainty ); // Compare uncertainty
}

// Implement by hand:
// REQUIRE( ( series_uncorrelated_deviation /= series ) == uncorrelated_deviation_one );
series_uncorrelated_deviation /= series;
s1 = series_uncorrelated_deviation;
s2 = uncorrelated_deviation_one;
REQUIRE ( s1.expansion_parameter == s2.expansion_parameter );
REQUIRE ( s1.get_order_min() == s2.get_order_min() );
REQUIRE ( s1.get_order_max() == s2.get_order_max() );
REQUIRE ( s1.get_truncated_above() != s2.get_truncated_above() );
for ( size_t idx = 0 ; idx < s1.get_order_max()-s1.get_order_min()+1 ; ++idx )
{
REQUIRE ( s1.get_content().at(idx).value == s2.get_content().at(idx).value ); // Compare value
REQUIRE ( s1.get_content().at(idx).uncertainty == s2.get_content().at(idx).uncertainty ); // Compare uncertainty
}

};

SECTION ( " series with one term in denominator does not get truncated " ) {

Expand Down

0 comments on commit e2aaa38

Please sign in to comment.