Skip to content

Commit 9efbf1b

Browse files
committed
added mutable keywords to polynomial root property.
1 parent b9d0ae5 commit 9efbf1b

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

math/mathmore/inc/Math/Polynomial.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,20 @@ class Polynomial : public ParamFunction<IParamGradFunction>,
116116
equation is very small. In that case it might be more robust to use the numerical method, by calling directly FindNumRoots()
117117
118118
*/
119-
const std::vector<std::complex <double> > & FindRoots();
119+
const std::vector<std::complex <double> > & FindRoots() const;
120120

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

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

134134
/**
135135
Order of Polynomial
@@ -166,8 +166,7 @@ class Polynomial : public ParamFunction<IParamGradFunction>,
166166
mutable std::vector<double> fDerived_params;
167167

168168
// roots
169-
170-
std::vector< std::complex < double > > fRoots;
169+
mutable std::vector< std::complex < double > > fRoots;
171170

172171
};
173172

math/mathmore/src/Polynomial.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ IGenFunction * Polynomial::Clone() const {
148148
}
149149

150150

151-
const std::vector< std::complex <double> > & Polynomial::FindRoots(){
151+
const std::vector< std::complex <double> > & Polynomial::FindRoots() const {
152152

153153

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

236236

237-
std::vector< double > Polynomial::FindRealRoots(){
237+
std::vector< double > Polynomial::FindRealRoots() const {
238238
FindRoots();
239239
std::vector<double> roots;
240240
roots.reserve(fOrder);
@@ -244,7 +244,7 @@ std::vector< double > Polynomial::FindRealRoots(){
244244
}
245245
return roots;
246246
}
247-
const std::vector< std::complex <double> > & Polynomial::FindNumRoots(){
247+
const std::vector< std::complex <double> > & Polynomial::FindNumRoots() const {
248248

249249

250250
// check if order is correct

0 commit comments

Comments
 (0)