Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tturocy committed Jan 3, 2025
1 parent b756bf6 commit d942e0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
15 changes: 6 additions & 9 deletions src/solvers/enumpoly/gpartltr.imp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ using namespace Gambit;
//---------------------------------------------------------------

/// Recursive generation of all partial derivatives of the root polynomial
template <class T>
void TreeOfPartials<T>::BuildTree(Node &n)
template <class T> void TreeOfPartials<T>::BuildTree(Node &n)
{
if (n.data.Degree() >= 1) {
for (int i = 1; i <= n.data.GetDimension(); i++) {
Expand All @@ -50,10 +49,9 @@ T TreeOfPartials<T>::ValueOfPartialOfRootPoly(const int coord, const Vector<T> &
}

template <class T>
T TreeOfPartials<T>::MaximalNonconstantContribution(const Node &n,
const Vector<T> &p,
const Vector<T> &halvesoflengths,
Vector<int> &wrtos) const
T TreeOfPartials<T>::MaximalNonconstantContribution(const Node &n, const Vector<T> &p,
const Vector<T> &halvesoflengths,
Vector<int> &wrtos) const
{
T answer = static_cast<T>(0);
int i = 1;
Expand Down Expand Up @@ -97,9 +95,8 @@ template <class T> bool TreeOfPartials<T>::PolyHasNoRootsIn(const Rectangle<T> &

template <class T> bool TreeOfPartials<T>::MultiaffinePolyHasNoRootsIn(const Rectangle<T> &r) const
{
T sign = (m_treeroot.data.Evaluate(r.Center()) > static_cast<T>(0))
? static_cast<T>(1)
: static_cast<T>(-1);
T sign = (m_treeroot.data.Evaluate(r.Center()) > static_cast<T>(0)) ? static_cast<T>(1)
: static_cast<T>(-1);

Array<int> zeros(GetDimension());
std::fill(zeros.begin(), zeros.end(), 0);
Expand Down
25 changes: 16 additions & 9 deletions src/solvers/enumpoly/gpoly.imp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
//-------------------------------------------------------------

template <class T>
List<Monomial<T>> Polynomial<T>::Adder(const List<Monomial<T>> &One, const List<Monomial<T>> &Two) const
List<Monomial<T>> Polynomial<T>::Adder(const List<Monomial<T>> &One,
const List<Monomial<T>> &Two) const
{
if (One.empty()) {
return Two;
Expand Down Expand Up @@ -78,7 +79,8 @@ List<Monomial<T>> Polynomial<T>::Adder(const List<Monomial<T>> &One, const List<
}

template <class T>
List<Monomial<T>> Polynomial<T>::Mult(const List<Monomial<T>> &One, const List<Monomial<T>> &Two) const
List<Monomial<T>> Polynomial<T>::Mult(const List<Monomial<T>> &One,
const List<Monomial<T>> &Two) const
{
List<Monomial<T>> answer;

Expand Down Expand Up @@ -165,7 +167,8 @@ template <class T> Polynomial<T> Polynomial<T>::DivideByPolynomial(const Polynom

while (remainder != zero) {
Polynomial<T> quot = remainder.LeadingCoefficient(last) / den.LeadingCoefficient(last);
Polynomial<T> power_of_last(Space, last, remainder.DegreeOfVar(last) - den.DegreeOfVar(last));
Polynomial<T> power_of_last(Space, last,
remainder.DegreeOfVar(last) - den.DegreeOfVar(last));
result += quot * power_of_last;
remainder -= quot * power_of_last * den;
}
Expand Down Expand Up @@ -203,14 +206,15 @@ template <class T> Polynomial<T> Polynomial<T>::LeadingCoefficient(int varnumber
for (size_t j = 1; j <= Terms.size(); j++) {
if (Terms[j].ExpV()[varnumber] == degree) {
newPoly.Terms.push_back(
Monomial<T>(Terms[j].Coef(), Terms[j].ExpV().WithZeroExponent(varnumber)));
Monomial<T>(Terms[j].Coef(), Terms[j].ExpV().WithZeroExponent(varnumber)));
}
}
return newPoly;
}

template <class T>
Polynomial<T> Polynomial<T>::TranslateOfMono(const Monomial<T> &m, const Vector<T> &new_origin) const
Polynomial<T> Polynomial<T>::TranslateOfMono(const Monomial<T> &m,
const Vector<T> &new_origin) const
{
Polynomial<T> answer(GetSpace(), static_cast<T>(1));
for (int i = 1; i <= GetDimension(); i++) {
Expand All @@ -236,7 +240,8 @@ template <class T> Polynomial<T> Polynomial<T>::TranslateOfPoly(const Vector<T>
}

template <class T>
Polynomial<T> Polynomial<T>::MonoInNewCoordinates(const Monomial<T> &m, const SquareMatrix<T> &M) const
Polynomial<T> Polynomial<T>::MonoInNewCoordinates(const Monomial<T> &m,
const SquareMatrix<T> &M) const
{
Polynomial<T> answer(Space, static_cast<T>(1));

Expand All @@ -256,7 +261,8 @@ Polynomial<T> Polynomial<T>::MonoInNewCoordinates(const Monomial<T> &m, const Sq
return answer;
}

template <class T> Polynomial<T> Polynomial<T>::PolyInNewCoordinates(const SquareMatrix<T> &M) const
template <class T>
Polynomial<T> Polynomial<T>::PolyInNewCoordinates(const SquareMatrix<T> &M) const
{
Polynomial<T> answer(Space);
for (const auto &term : Terms) {
Expand All @@ -279,8 +285,9 @@ template <class T> T Polynomial<T>::MaximalValueOfNonlinearPart(const T &radius)
template <class T> Polynomial<T> Polynomial<T>::Normalize() const
{
auto maxcoeff =
std::max_element(Terms.begin(), Terms.end(),
[](const Monomial<T> &a, const Monomial<T> &b) { return a.Coef() < b.Coef(); });
std::max_element(Terms.begin(), Terms.end(), [](const Monomial<T> &a, const Monomial<T> &b) {
return a.Coef() < b.Coef();
});
if (maxcoeff->Coef() < static_cast<T>(0.000000001)) {
return *this;
}
Expand Down

0 comments on commit d942e0a

Please sign in to comment.