aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test
diff options
context:
space:
mode:
authorGravatar Thomas Capricelli <orzel@freehackers.org>2009-08-19 18:32:37 +0200
committerGravatar Thomas Capricelli <orzel@freehackers.org>2009-08-19 18:32:37 +0200
commit703198a1a6f1a4e22958852974dbf6e854610d71 (patch)
tree7f510daf224cfa83de3a7e6087b0e7675ef9c275 /unsupported/test
parent3f63d6f97fd3dbd2cf7a70c5cdda8f5b82b3ab6a (diff)
wrapper for chkder() : this was the last wrapper missing
Diffstat (limited to 'unsupported/test')
-rw-r--r--unsupported/test/NonLinear.cpp56
1 files changed, 22 insertions, 34 deletions
diff --git a/unsupported/test/NonLinear.cpp b/unsupported/test/NonLinear.cpp
index 87bbf5495..ddd8c3b66 100644
--- a/unsupported/test/NonLinear.cpp
+++ b/unsupported/test/NonLinear.cpp
@@ -57,59 +57,47 @@ int fcn_chkder(int /*m*/, int /*n*/, const double *x, double *fvec, double *fjac
void testChkder()
{
- int i, m, n, ldfjac;
- double x[3], fvec[15], fjac[15*3], xp[3], fvecp[15],
- err[15];
-
- m = 15;
- n = 3;
+ int m=15, n=3;
+ Eigen::VectorXd x(n), fvec(m), xp, fvecp(m), err;
+ Eigen::MatrixXd fjac(m,n);
+ VectorXi ipvt;
/* the following values should be suitable for */
/* checking the jacobian matrix. */
+ x << 9.2e-1, 1.3e-1, 5.4e-1;
- x[1-1] = 9.2e-1;
- x[2-1] = 1.3e-1;
- x[3-1] = 5.4e-1;
-
- ldfjac = 15;
-
- chkder(m, n, x, fvec, fjac, ldfjac, xp, fvecp, 1, err);
- fcn_chkder(m, n, x, fvec, fjac, ldfjac, 1);
- fcn_chkder(m, n, x, fvec, fjac, ldfjac, 2);
- fcn_chkder(m, n, xp, fvecp, fjac, ldfjac, 1);
- chkder(m, n, x, fvec, fjac, ldfjac, xp, fvecp, 2, err);
-
- for (i=1; i<=m; i++)
- {
- fvecp[i-1] = fvecp[i-1] - fvec[i-1];
- }
+ ei_chkder<double>(x, fvec, fjac, xp, fvecp, 1, err);
+ fcn_chkder(m, n, x.data(), fvec.data(), fjac.data(), m, 1);
+ fcn_chkder(m, n, x.data(), fvec.data(), fjac.data(), m, 2);
+ fcn_chkder(m, n, xp.data(), fvecp.data(), fjac.data(), m, 1);
+ ei_chkder<double>(x, fvec, fjac, xp, fvecp, 2, err);
+ fvecp -= fvec;
- double fvec_ref[] = {
+ // check those
+ VectorXd fvec_ref(m), fvecp_ref(m), err_ref(m);
+ fvec_ref <<
-1.181606, -1.429655, -1.606344,
-1.745269, -1.840654, -1.921586,
-1.984141, -2.022537, -2.468977,
-2.827562, -3.473582, -4.437612,
- -6.047662, -9.267761, -18.91806
- };
- double fvecp_ref[] = {
+ -6.047662, -9.267761, -18.91806;
+ fvecp_ref <<
-7.724666e-09, -3.432406e-09, -2.034843e-10,
2.313685e-09, 4.331078e-09, 5.984096e-09,
7.363281e-09, 8.53147e-09, 1.488591e-08,
2.33585e-08, 3.522012e-08, 5.301255e-08,
- 8.26666e-08, 1.419747e-07, 3.19899e-07
- };
- double err_ref[] = {
+ 8.26666e-08, 1.419747e-07, 3.19899e-07;
+ err_ref <<
0.1141397, 0.09943516, 0.09674474,
0.09980447, 0.1073116, 0.1220445,
0.1526814, 1, 1,
1, 1, 1,
- 1, 1, 1
- };
+ 1, 1, 1;
- for (i=1; i<=m; i++) VERIFY_IS_APPROX(fvec[i-1], fvec_ref[i-1]);
- for (i=1; i<=m; i++) VERIFY_IS_APPROX(fvecp[i-1], fvecp_ref[i-1]);
- for (i=1; i<=m; i++) VERIFY_IS_APPROX(err[i-1], err_ref[i-1]);
+ VERIFY_IS_APPROX(fvec, fvec_ref);
+ VERIFY_IS_APPROX(fvecp, fvecp_ref);
+ VERIFY_IS_APPROX(err, err_ref);
}