Adds a Durand-Kerner polynomial solver to core and improves solver API#1865
Conversation
| */ | ||
| template <typename ScalarType> | ||
| ScalarType evaluate_polynomial(ArrayView<const double> coeffs_descending, const ScalarType& x) | ||
| { |
There was a problem hiding this comment.
I noticed that the tparam doc says ScalarType is double or Complex. Is a static_assert() for that in order here, or might be useful to pass Vector<double,3> or other things in down the road?
There was a problem hiding this comment.
I added a static_assert. If we need more flexibility later, we can modify the function/signature.
|
|
||
| result.roots.resize(effective_degree); | ||
| // Powers of this non-real base with magnitude around 1 give deterministic, distinct initial guesses. | ||
| const Complex seed_center {0.4, 0.9}; |
There was a problem hiding this comment.
Is there anything special about this particular seed value? Could there ever be utility to letting a user pick the seed value? I know that can help a lot in regular Newton solvers.
There was a problem hiding this comment.
It was the value on the wikipedia page and they explicitly say it's not special :)
Sure -- we can pass update the API to optionally pass in a seed.
Per PR request.
0ac7df3 to
a1f685a
Compare
Summary
axom::ArrayViews instead of pointers to C-style arrays. The latter have been deprecatedaxom::Array::pop_back()for compatibility withstd::vectorDurand-Kerner solver
Here's a visualization (courtesy of claude) of how the solver works for the polynomial:$z^3-1$ , initialized with three seed points near the unit circle -- powers of $.4+.9i$