Skip to content

Commit 2cee20e

Browse files
committed
[math] Make ScipyMinimizer compile again
1 parent 706ae0e commit 2cee20e

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

math/scipy/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Scipy
99
Math/ScipyMinimizer.h
1010
LINKDEF
1111
Math/LinkDef.h
12-
LIBRARIES ${PYTHON_LIBRARIES_Development_Main}
12+
LIBRARIES
13+
Python3::NumPy
14+
Python3::Python
1315
SOURCES
1416
src/ScipyMinimizer.cxx
1517
DEPENDENCIES Core MathCore RIO

math/scipy/inc/Math/ScipyMinimizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ScipyMinimizer : public BasicMinimizer {
8484
PyObject *fBoundsMod;
8585
PyObject *fConstraintsList; /// contraints functions
8686
GenAlgoOptions *fExtraOpts;
87-
std::function<bool(const std::vector<double> &, double *)> fHessianFunc;
87+
std::function<bool(std::span<const double>, double *)> fHessianFunc;
8888
unsigned int fConstN;
8989
unsigned int fCalls;
9090

@@ -158,7 +158,7 @@ class ScipyMinimizer : public BasicMinimizer {
158158
/// method to perform the minimization
159159
virtual bool Minimize() override;
160160

161-
virtual void SetHessianFunction(std::function<bool(const std::vector<double> &, double *)>) override;
161+
virtual void SetHessianFunction(std::function<bool(std::span<const double>, double *)>) override;
162162

163163
protected:
164164
ClassDef(ScipyMinimizer, 0) //

math/scipy/src/ScipyMinimizer.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <Math/IFunction.h>
66
#include <Math/FitMethodFunction.h>
77
#include <Math/GenAlgoOptions.h>
8+
#include <Math/Error.h>
89
#include <TString.h>
910
#include <iostream>
1011

@@ -352,7 +353,7 @@ void ScipyMinimizer::PyRunString(TString code, TString errorMessage, int start)
352353
}
353354

354355
//_______________________________________________________________________
355-
void ScipyMinimizer::SetHessianFunction(std::function<bool(const std::vector<double> &, double *)> func)
356+
void ScipyMinimizer::SetHessianFunction(std::function<bool(std::span<const double>, double *)> func)
356357
{
357358
fHessianFunc = func;
358359
}

math/scipy/test/testScipyMinimizer.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ double RosenBrockGrad(const double *x, unsigned int ipar)
2828
return 200 * (x[1] - x[0] * x[0]);
2929
}
3030
// Hessian function
31-
bool RosenBrockHessian(const std::vector<double> &xx, double *hess)
31+
bool RosenBrockHessian(std::span<const double> xx, double *hess)
3232
{
3333
const double x = xx[0];
3434
const double y = xx[1];
@@ -126,4 +126,4 @@ TEST_F(ScipyFitClass, FitContraint) // using constraint function
126126
ASSERT_NEAR(1, x[1], 0.5);
127127
ASSERT_NEAR(0, RosenBrock(x), 0.5);
128128
}
129-
}
129+
}

tutorials/math/fit/scipy.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ double RosenBrockGrad(const double *x, unsigned int ipar)
2323
return 200 * (x[1] - x[0] * x[0]);
2424
}
2525

26-
bool RosenBrockHessian(const std::vector<double> &xx, double *hess)
26+
bool RosenBrockHessian(std::span<const double> xx, double *hess)
2727
{
2828
const double x = xx[0];
2929
const double y = xx[1];
@@ -78,4 +78,4 @@ int scipy()
7878
int main()
7979
{
8080
return scipy();
81-
}
81+
}

0 commit comments

Comments
 (0)