mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 20:26:03 +08:00
eigenize the test a little more
This commit is contained in:
parent
f19eda7cf6
commit
7db4052749
@ -34,7 +34,7 @@ int ei_hybrd1(
|
|||||||
VectorType &fvec,
|
VectorType &fvec,
|
||||||
// ei_traits<VectorType>::Scalar tol
|
// ei_traits<VectorType>::Scalar tol
|
||||||
double tol
|
double tol
|
||||||
// = ei::sqrt(machine_epsilon<VectorType::Scalar>())
|
// = ei_sqrt(machine_epsilon<VectorType::Scalar>())
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef typename VectorType::Scalar Scalar;
|
typedef typename VectorType::Scalar Scalar;
|
||||||
|
@ -491,36 +491,28 @@ struct myfunctor {
|
|||||||
|
|
||||||
void testHybrd1()
|
void testHybrd1()
|
||||||
{
|
{
|
||||||
int j, n=9, info;
|
int n=9, info;
|
||||||
double fnorm;
|
Eigen::VectorXd x(n), fvec(n);
|
||||||
Eigen::VectorXd x(9), fvec(9);
|
|
||||||
|
|
||||||
|
/* the following starting values provide a rough solution. */
|
||||||
/* the following starting values provide a rough solution. */
|
x.setConstant(n, -1.);
|
||||||
|
|
||||||
for (j=1; j<=n; j++)
|
|
||||||
{
|
|
||||||
x[j-1] = -1.;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set tol to the square root of the machine precision. */
|
/* set tol to the square root of the machine precision. */
|
||||||
/* unless high solutions are required, */
|
/* unless high solutions are required, */
|
||||||
/* this is the recommended setting. */
|
/* this is the recommended setting. */
|
||||||
|
|
||||||
info = ei_hybrd1<myfunctor,VectorXd>(x, fvec, sqrt(dpmpar(1)));
|
info = ei_hybrd1<myfunctor,VectorXd>(x, fvec, ei_sqrt(machine_epsilon<double>()));
|
||||||
|
|
||||||
fnorm = enorm(fvec.size(), fvec.data());
|
// check return value
|
||||||
|
VERIFY( 1 == info);
|
||||||
|
|
||||||
|
// check norm
|
||||||
VERIFY_IS_APPROX(fvec.norm(), 1.192636e-08);
|
VERIFY_IS_APPROX(fvec.norm(), 1.192636e-08);
|
||||||
|
|
||||||
VERIFY(info==1);
|
// check x
|
||||||
|
VectorXd x_ref;
|
||||||
double x_ref[] = {
|
x_ref << -0.5706545, -0.6816283, -0.7017325, -0.7042129, -0.701369, -0.6918656, -0.665792, -0.5960342, -0.4164121;
|
||||||
-0.5706545, -0.6816283, -0.7017325,
|
VERIFY_IS_APPROX(x, x_ref);
|
||||||
-0.7042129, -0.701369, -0.6918656,
|
|
||||||
-0.665792, -0.5960342, -0.4164121
|
|
||||||
};
|
|
||||||
for (j=1; j<=n; j++) VERIFY_IS_APPROX(x[j-1], x_ref[j-1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int fcn_hybrd(void * /*p*/, int n, const double *x, double *fvec, int iflag)
|
int fcn_hybrd(void * /*p*/, int n, const double *x, double *fvec, int iflag)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user