Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions math/mathmore/inc/Math/Polynomial.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@ class Polynomial : public ParamFunction<IParamGradFunction>,
equation is very small. In that case it might be more robust to use the numerical method, by calling directly FindNumRoots()

*/
const std::vector<std::complex <double> > & FindRoots();
const std::vector<std::complex <double> > & FindRoots() const;

/**
Find the only the real polynomial roots.
For n <= 4, the roots are found analytically while for larger order an iterative numerical method is used
The numerical method used is from GSL (see <A HREF="https://www.gnu.org/software/gsl/doc/html/poly.html">documentation</A> )
*/
std::vector<double > FindRealRoots();
std::vector<double > FindRealRoots() const;

/**
Find the polynomial roots using always an iterative numerical methods
The numerical method used is from GSL (see <A HREF="https://www.gnu.org/software/gsl/doc/html/poly.html">documentation</A> )
*/
const std::vector<std::complex <double> > & FindNumRoots();
const std::vector<std::complex <double> > & FindNumRoots() const;

/**
Order of Polynomial
Expand Down Expand Up @@ -166,8 +166,7 @@ class Polynomial : public ParamFunction<IParamGradFunction>,
mutable std::vector<double> fDerived_params;

// roots

std::vector< std::complex < double > > fRoots;
mutable std::vector< std::complex < double > > fRoots;

};

Expand Down
6 changes: 3 additions & 3 deletions math/mathmore/src/Polynomial.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ IGenFunction * Polynomial::Clone() const {
}


const std::vector< std::complex <double> > & Polynomial::FindRoots(){
const std::vector< std::complex <double> > & Polynomial::FindRoots() const {


// check if order is correct
Expand Down Expand Up @@ -234,7 +234,7 @@ const std::vector< std::complex <double> > & Polynomial::FindRoots(){
}


std::vector< double > Polynomial::FindRealRoots(){
std::vector< double > Polynomial::FindRealRoots() const {
FindRoots();
std::vector<double> roots;
roots.reserve(fOrder);
Expand All @@ -244,7 +244,7 @@ std::vector< double > Polynomial::FindRealRoots(){
}
return roots;
}
const std::vector< std::complex <double> > & Polynomial::FindNumRoots(){
const std::vector< std::complex <double> > & Polynomial::FindNumRoots() const {


// check if order is correct
Expand Down
Loading