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

daisytuner / sdfglib / 16069945621

04 Jul 2025 08:56AM UTC coverage: 64.375% (-0.2%) from 64.606%
16069945621

push

github

web-flow
Merge pull request #137 from daisytuner/clang-format

runs clang-format on codebase

609 of 827 new or added lines in 63 files covered. (73.64%)

46 existing lines in 30 files now uncovered.

8578 of 13325 relevant lines covered (64.38%)

177.24 hits per line

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

64.71
/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
bool is_monotonic_affine(const Expression& expr, const Symbol& sym, const Assumptions& assums) {
237✔
11
    SymbolVec symbols = {sym};
237✔
12
    auto poly = polynomial(expr, symbols);
237✔
13
    if (poly == SymEngine::null) {
237✔
14
        return false;
×
15
    }
16
    auto coeffs = affine_coefficients(poly, symbols);
237✔
17
    if (coeffs.empty()) {
237✔
18
        return false;
×
19
    }
20
    auto mul = minimum(coeffs[sym], {}, assums);
237✔
21
    if (mul == SymEngine::null) {
237✔
22
        return false;
×
23
    }
24
    auto offset = minimum(coeffs[symbol("__daisy_constant__")], {}, assums);
237✔
25
    if (offset == SymEngine::null) {
237✔
26
        return false;
1✔
27
    }
28
    if (!SymEngine::is_a<SymEngine::Integer>(*mul) || !SymEngine::is_a<SymEngine::Integer>(*offset)) {
236✔
UNCOV
29
        return false;
×
30
    }
31
    auto mul_int = SymEngine::rcp_dynamic_cast<const SymEngine::Integer>(mul);
236✔
32
    auto offset_int = SymEngine::rcp_dynamic_cast<const SymEngine::Integer>(offset);
236✔
33
    if (mul_int->as_int() <= 0 || offset_int->as_int() <= 0) {
236✔
34
        return false;
1✔
35
    }
36

37
    return true;
235✔
38
}
237✔
39

40
bool is_monotonic_pow(const Expression& expr, const Symbol& sym, const Assumptions& assums) {
2✔
41
    if (SymEngine::is_a<SymEngine::Pow>(*expr)) {
2✔
42
        auto pow = SymEngine::rcp_dynamic_cast<const SymEngine::Pow>(expr);
×
43
        auto base = pow->get_base();
×
44
        auto exp = pow->get_exp();
×
NEW
45
        if (SymEngine::is_a<SymEngine::Integer>(*exp) && SymEngine::is_a<SymEngine::Symbol>(*base)) {
×
46
            auto exp_int = SymEngine::rcp_dynamic_cast<const SymEngine::Integer>(exp);
×
47
            if (exp_int->as_int() <= 0) {
×
48
                return false;
×
49
            }
50
            auto base_sym = SymEngine::rcp_static_cast<const SymEngine::Symbol>(base);
×
51
            auto ub_sym = minimum(base_sym, {}, assums);
×
52
            if (ub_sym == SymEngine::null) {
×
53
                return false;
×
54
            }
55
            auto positive = symbolic::Ge(ub_sym, symbolic::integer(0));
×
56
            return symbolic::is_true(positive);
×
57
        }
×
58
    }
×
59

60
    return false;
2✔
61
}
2✔
62

63
bool is_monotonic(const Expression& expr, const Symbol& sym, const Assumptions& assums) {
237✔
64
    if (is_monotonic_affine(expr, sym, assums)) {
237✔
65
        return true;
235✔
66
    }
67
    return is_monotonic_pow(expr, sym, assums);
2✔
68
}
237✔
69

70
bool is_contiguous(const Expression& expr, const Symbol& sym, const Assumptions& assums) {
17✔
71
    SymbolVec symbols = {sym};
17✔
72
    auto poly = polynomial(expr, symbols);
17✔
73
    if (poly == SymEngine::null) {
17✔
74
        return false;
×
75
    }
76
    auto coeffs = affine_coefficients(poly, symbols);
17✔
77
    if (coeffs.empty()) {
17✔
78
        return false;
×
79
    }
80
    auto mul = minimum(coeffs[sym], {}, assums);
17✔
81
    if (mul == SymEngine::null) {
17✔
82
        return false;
×
83
    }
84
    auto offset = minimum(coeffs[symbol("__daisy_constant__")], {}, assums);
17✔
85
    if (offset == SymEngine::null) {
17✔
86
        return false;
×
87
    }
88
    if (!SymEngine::is_a<SymEngine::Integer>(*mul) || !SymEngine::is_a<SymEngine::Integer>(*offset)) {
17✔
UNCOV
89
        return false;
×
90
    }
91
    auto mul_int = SymEngine::rcp_dynamic_cast<const SymEngine::Integer>(mul);
17✔
92
    auto offset_int = SymEngine::rcp_dynamic_cast<const SymEngine::Integer>(offset);
17✔
93
    if (mul_int->as_int() == 1 && offset_int->as_int() == 1) {
17✔
94
        return true;
16✔
95
    }
96

97
    return false;
1✔
98
}
17✔
99

100
} // namespace series
101
} // namespace symbolic
102
} // 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