MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / dTestSolveLCP

Function dTestSolveLCP

3rd_party/Src/ode/ode/src/lcp.cpp:1366–1472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1364// accuracy and timing test
1365#if 0//def _DEBUG
1366extern "C" void dTestSolveLCP()
1367{
1368 int n = 100;
1369 int i,nskip = dPAD(n);
1370 const dReal tol = REAL(1e-9);
1371 printf ("dTestSolveLCP()\n");
1372
1373 dReal *A = (dReal*) ALLOCA (n*nskip*sizeof(dReal));
1374 dReal *x = (dReal*) ALLOCA (n*sizeof(dReal));
1375 dReal *b = (dReal*) ALLOCA (n*sizeof(dReal));
1376 dReal *w = (dReal*) ALLOCA (n*sizeof(dReal));
1377 dReal *lo = (dReal*) ALLOCA (n*sizeof(dReal));
1378 dReal *hi = (dReal*) ALLOCA (n*sizeof(dReal));
1379
1380 dReal *A2 = (dReal*) ALLOCA (n*nskip*sizeof(dReal));
1381 dReal *b2 = (dReal*) ALLOCA (n*sizeof(dReal));
1382 dReal *lo2 = (dReal*) ALLOCA (n*sizeof(dReal));
1383 dReal *hi2 = (dReal*) ALLOCA (n*sizeof(dReal));
1384 dReal *tmp1 = (dReal*) ALLOCA (n*sizeof(dReal));
1385 dReal *tmp2 = (dReal*) ALLOCA (n*sizeof(dReal));
1386
1387 double total_time = 0;
1388 for (int count=0; count < 1000; count++) {
1389
1390 // form (A,b) = a random positive definite LCP problem
1391 dMakeRandomMatrix (A2,n,n,1.0);
1392 dMultiply2 (A,A2,A2,n,n,n);
1393 dMakeRandomMatrix (x,n,1,1.0);
1394 dMultiply0 (b,A,x,n,n,1);
1395 for (i=0; i<n; i++) b[i] += (dRandReal()*REAL(0.2))-REAL(0.1);
1396
1397 // choose `nub' in the range 0..n-1
1398 int nub = 50; //dRandInt (n);
1399
1400 // make limits
1401 for (i=0; i<nub; i++) lo[i] = -dInfinity;
1402 for (i=0; i<nub; i++) hi[i] = dInfinity;
1403 //for (i=nub; i<n; i++) lo[i] = 0;
1404 //for (i=nub; i<n; i++) hi[i] = dInfinity;
1405 //for (i=nub; i<n; i++) lo[i] = -dInfinity;
1406 //for (i=nub; i<n; i++) hi[i] = 0;
1407 for (i=nub; i<n; i++) lo[i] = -(dRandReal()*REAL(1.0))-REAL(0.01);
1408 for (i=nub; i<n; i++) hi[i] = (dRandReal()*REAL(1.0))+REAL(0.01);
1409
1410 // set a few limits to lo=hi=0
1411 /*
1412 for (i=0; i<10; i++) {
1413 int j = dRandInt (n-nub) + nub;
1414 lo[j] = 0;
1415 hi[j] = 0;
1416 }
1417 */
1418
1419 // solve the LCP. we must make copy of A,b,lo,hi (A2,b2,lo2,hi2) for
1420 // SolveLCP() to permute. also, we'll clear the upper triangle of A2 to
1421 // ensure that it doesn't get referenced (if it does, the answer will be
1422 // wrong).
1423

Callers

nothing calls this directly

Calls 13

dMakeRandomMatrixFunction · 0.85
dMultiply2Function · 0.85
dMultiply0Function · 0.85
dRandRealFunction · 0.85
dClearUpperTriangleFunction · 0.85
dSetZeroFunction · 0.85
dStopwatchResetFunction · 0.85
dStopwatchStartFunction · 0.85
dSolveLCPFunction · 0.85
dStopwatchStopFunction · 0.85
dStopwatchTimeFunction · 0.85
dMaxDifferenceFunction · 0.85

Tested by

no test coverage detected