GCC Code Coverage Report


Directory: ./
File: src/2geom/sbasis-poly.cpp
Date: 2024-03-18 17:01:34
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 2 2 100.0%
Branches: 26 46 56.5%

Line Branch Exec Source
1 #include <2geom/sbasis-poly.h>
2
3 namespace Geom{
4
5 /** Changes the basis of p to be sbasis.
6 \param p the Monomial basis polynomial
7 \returns the Symmetric basis polynomial
8
9 This algorithm is horribly slow and numerically terrible. Only for testing.
10 */
11 6 SBasis poly_to_sbasis(Poly const & p) {
12
1/2
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 SBasis x = Linear(0, 1);
13
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 SBasis r;
14
15
2/2
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 6 times.
38 for(int i = p.size()-1; i >= 0; i--) {
16
4/8
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 32 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 32 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 32 times.
✗ Branch 18 not taken.
32 r = SBasis(Linear(p[i], p[i])) + multiply(x, r);
17 }
18 6 r.normalize();
19 12 return r;
20
21 6 }
22
23 /** Changes the basis of p to be monomial.
24 \param p the Symmetric basis polynomial
25 \returns the Monomial basis polynomial
26
27 This algorithm is horribly slow and numerically terrible. Only for testing.
28 */
29 22 Poly sbasis_to_poly(SBasis const & sb) {
30
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
22 if(sb.isZero())
31 1 return Poly();
32 21 Poly S; // (1-x)x = -1*x^2 + 1*x + 0
33 21 Poly A, B;
34
1/2
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
21 B.push_back(0);
35
1/2
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
21 B.push_back(1);
36
1/2
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
21 A.push_back(1);
37
1/2
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
21 A.push_back(-1);
38
2/4
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
21 S = A*B;
39 21 Poly r;
40
41
2/2
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 21 times.
108 for(int i = sb.size()-1; i >= 0; i--) {
42
6/12
✓ Branch 6 taken 87 times.
✗ Branch 7 not taken.
✓ Branch 14 taken 87 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 87 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 87 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 87 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 87 times.
✗ Branch 28 not taken.
87 r = S*r + sb[i][0]*A + sb[i][1]*B;
43 }
44
1/2
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
21 r.normalize();
45
1/2
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
21 return r;
46 21 }
47
48 };
49
50 /*
51 Local Variables:
52 mode:c++
53 c-file-style:"stroustrup"
54 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
55 indent-tabs-mode:nil
56 fill-column:99
57 End:
58 */
59 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
60