11using DataStructures
22
33# this is the main heurisctic used to find the test fragments
4- function generate_basis (eq, x)
4+ function generate_basis (eq, x; homotopy= false )
5+ if homotopy
6+ return generate_homotopy (eq, x)
7+ end
8+
59 eq = expand (eq)
610 S = Set {Any} ()
711 for t in terms (eq)
812 q = t / coef (t, x)
913 f = kernel (q)
10- C₁ = closure (f, x) # find_candidates(f, x)
11- C₂ = find_candidates_nonsolvable (q * inverse (f), x)
12- # C₂ = generate_by_parts(q * inverse(f), x)
14+
15+ C₁ = closure (f, x)
16+ p = q * inverse (f)
17+
18+ if homotopy
19+ if isdependent (p, x)
20+ C₂ = generate_homotopy2 (p, x)
21+ else
22+ C₂ = 1
23+ end
24+ else
25+ C₂ = find_candidates_nonsolvable (p, x)
26+ end
1327
1428 for c₁ in C₁
1529 enqueue_expr_ex! (S, c₁, x)
@@ -28,6 +42,15 @@ function generate_basis(eq, x)
2842 return unique ([one (x); [s for s in S]])
2943end
3044
45+ function expand_basis (basis, x; homotopy= false )
46+ if homotopy
47+ I, deg = homotopy_integrand (sum (basis), x)
48+ return expand_integrand (I, x, deg)
49+ else
50+ return unique ([basis; basis* x])
51+ end
52+ end
53+
3154function closure (eq, x; max_terms= 50 )
3255 if ! isdependent (eq, x) return [one (x)] end
3356 D = Differential (x)
0 commit comments