• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / sdfglib / 20186550381

11 Dec 2025 09:41PM UTC coverage: 40.179% (-0.002%) from 40.181%
20186550381

push

github

lukastruemper
adds guards for as init in series analysis

13596 of 43803 branches covered (31.04%)

Branch coverage included in aggregate %.

11 of 12 new or added lines in 1 file covered. (91.67%)

3 existing lines in 1 file now uncovered.

11615 of 18943 relevant lines covered (61.32%)

93.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.36
/src/symbolic/series.cpp
1
#include "sdfg/symbolic/series.h"
2

3
#include "sdfg/symbolic/extreme_values.h"
4
#include "sdfg/symbolic/polynomials.h"
5

6
namespace sdfg {
7
namespace symbolic {
8
namespace series {
9

10
std::pair<bool, std::pair<Integer, Integer>>
11
affine_int_coeffs(const Expression expr, const Symbol sym, const Assumptions& assums) {
327✔
12
    SymbolVec symbols = {sym};
327!
13
    auto poly = polynomial(expr, symbols);
327!
14
    if (poly == SymEngine::null) {
327!
15
        return {false, {integer(0), integer(0)}};
×
16
    }
17
    auto coeffs = affine_coefficients(poly, symbols);
327!
18
    if (coeffs.empty()) {
327!
19
        return {false, {integer(0), integer(0)}};
×
20
    }
21
    auto mul = minimum(coeffs[sym], {}, assums);
327!
22
    if (mul == SymEngine::null) {
327!
23
        return {false, {integer(0), integer(0)}};
×
24
    }
25
    auto offset = minimum(coeffs[symbol("__daisy_constant__")], {}, assums);
327!
26
    if (offset == SymEngine::null) {
327!
27
        return {false, {integer(0), integer(0)}};
1!
28
    }
29
    if (!SymEngine::is_a<SymEngine::Integer>(*mul) || !SymEngine::is_a<SymEngine::Integer>(*offset)) {
326!
30
        return {false, {integer(0), integer(0)}};
×
31
    }
32
    auto mul_int = SymEngine::rcp_dynamic_cast<const SymEngine::Integer>(mul);
326!
33
    auto offset_int = SymEngine::rcp_dynamic_cast<const SymEngine::Integer>(offset);
326!
34
    return {true, {mul_int, offset_int}};
326!
35
}
327✔
36

37
bool is_monotonic_affine(const Expression expr, const Symbol sym, const Assumptions& assums) {
198✔
38
    auto [success, coeffs] = affine_int_coeffs(expr, sym, assums);
198!
39
    if (!success) {
198✔
40
        return false;
1✔
41
    }
42
    auto [mul_int, offset_int] = coeffs;
394!
43
    try {
44
        signed long mul_value = mul_int->as_int();
197!
45
        signed long offset_value = offset_int->as_int();
197!
46
        if (mul_value > 0 && offset_value > 0) {
197✔
47
            return true;
193✔
48
        }
49
    } catch (SymEngine::SymEngineException&) {
4!
UNCOV
50
        return false;
×
UNCOV
51
    }
×
52

53
    return false;
4✔
54
}
198✔
55

56
bool is_contiguous_affine(const Expression expr, const Symbol sym, const Assumptions& assums) {
121✔
57
    auto [success, coeffs] = affine_int_coeffs(expr, sym, assums);
121!
58
    if (!success) {
121!
59
        return false;
×
60
    }
61
    auto [mul_int, offset_int] = coeffs;
242!
62
    try {
63
        signed long mul_value = mul_int->as_int();
121!
64
        signed long offset_value = offset_int->as_int();
121!
65
        if (mul_value == 1 && offset_value == 1) {
121✔
66
            return true;
108✔
67
        }
68
    } catch (SymEngine::SymEngineException&) {
13!
NEW
69
        return false;
×
UNCOV
70
    }
×
71

72
    return false;
13✔
73
}
121✔
74

75
bool is_monotonic_pow(const Expression expr, const Symbol sym, const Assumptions& assums) {
5✔
76
    if (SymEngine::is_a<SymEngine::Pow>(*expr)) {
5!
77
        auto pow = SymEngine::rcp_dynamic_cast<const SymEngine::Pow>(expr);
×
78
        auto base = pow->get_base();
×
79
        auto exp = pow->get_exp();
×
80
        if (SymEngine::is_a<SymEngine::Integer>(*exp) && SymEngine::is_a<SymEngine::Symbol>(*base)) {
×
81
            auto exp_int = SymEngine::rcp_dynamic_cast<const SymEngine::Integer>(exp);
×
82
            if (exp_int->as_int() <= 0) {
×
83
                return false;
×
84
            }
85
            auto base_sym = SymEngine::rcp_static_cast<const SymEngine::Symbol>(base);
×
86
            auto ub_sym = minimum(base_sym, {}, assums);
×
87
            if (ub_sym == SymEngine::null) {
×
88
                return false;
×
89
            }
90
            auto positive = symbolic::Ge(ub_sym, symbolic::integer(0));
×
91
            return symbolic::is_true(positive);
×
92
        }
×
93
    }
×
94

95
    return false;
5✔
96
}
5✔
97

98
bool is_monotonic(const Expression expr, const Symbol sym, const Assumptions& assums) {
198✔
99
    if (is_monotonic_affine(expr, sym, assums)) {
198!
100
        return true;
193✔
101
    }
102
    return is_monotonic_pow(expr, sym, assums);
5!
103
}
198✔
104

105
bool is_contiguous(const Expression expr, const Symbol sym, const Assumptions& assums) {
121✔
106
    if (is_contiguous_affine(expr, sym, assums)) {
121!
107
        return true;
108✔
108
    }
109
    return false;
13✔
110
}
121✔
111

112
} // namespace series
113
} // namespace symbolic
114
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc