1
// Copyright (C) 2005 Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2005-02-03
5
// Last changed: 2006-07-04
7
// This example demonstrates the homotopy for finding
8
// all solutions of a system of polynomial equations
9
// for a couple of simple test systems taken from
10
// Alexander P. Morgan, ACM TOMS 1983.
14
using namespace dolfin;
16
class Quadratic : public Homotopy
20
Quadratic() : Homotopy(1) {}
22
void F(const complex z[], complex y[])
24
y[0] = 1.0 - z[0]*z[0];
27
void JF(const complex z[], const complex x[], complex y[])
29
y[0] = - 2.0*z[0]*x[0];
32
unsigned int degree(unsigned int i) const
39
class Cubic : public Homotopy
43
Cubic() : Homotopy(2) {}
45
void F(const complex z[], complex y[])
47
y[0] = 4.0*z[0]*z[0]*z[0] - 3.0*z[0] - z[1];
48
y[1] = z[0]*z[0] - z[1];
51
void JF(const complex z[], const complex x[], complex y[])
53
y[0] = 12.0*z[0]*z[0]*x[0] - 3.0*x[0] - x[1];
54
y[1] = 2.0*z[0]*x[0] - x[1];
57
unsigned int degree(unsigned int i) const
67
int main(int argc, char* argv[])
69
dolfin_init(argc, argv);
71
dolfin_set("ODE method", "cg");
72
dolfin_set("ODE order", 1);
73
dolfin_set("ODE tolerance", 0.05);
74
dolfin_set("homotopy monitoring", true);
75
dolfin_set("homotopy randomize", false);