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

Method nextMatrix

3rd_party/Src/ode/ode/src/testing.cpp:60–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60dReal dMatrixComparison::nextMatrix (dReal *A, int n, int m, int lower_tri, const char *name, ...)
61{
62 if (A==0 || n < 1 || m < 1 || name==0) dDebug (0,"bad args to nextMatrix");
63 int num = n*dPAD(m);
64
65 if (afterfirst==0) {
66 dMatInfo *mi = (dMatInfo*) dAlloc (sizeof(dMatInfo));
67 mi->n = n;
68 mi->m = m;
69 mi->size = num * sizeof(dReal);
70 mi->data = (dReal*) dAlloc (mi->size);
71 memcpy (mi->data,A,mi->size);
72
73 va_list ap;
74 va_start (ap,name);
75 vsprintf (mi->name,name,ap);
76 if (strlen(mi->name) >= sizeof (mi->name)) dDebug (0,"name too long");
77
78 mat.push (mi);
79 return 0;
80 }
81 else {
82 if (lower_tri && n != m)
83 dDebug (0,"dMatrixComparison, lower triangular matrix must be square");
84 if (index >= mat.size()) dDebug (0,"dMatrixComparison, too many matrices");
85 dMatInfo *mp = mat[index];
86 index++;
87
88 dMatInfo mi;
89 va_list ap;
90 va_start (ap,name);
91 vsprintf (mi.name,name,ap);
92 if (strlen(mi.name) >= sizeof (mi.name)) dDebug (0,"name too long");
93
94 if (strcmp(mp->name,mi.name) != 0)
95 dDebug (0,"dMatrixComparison, name mismatch (\"%s\" and \"%s\")",
96 mp->name,mi.name);
97 if (mp->n != n || mp->m != m)
98 dDebug (0,"dMatrixComparison, size mismatch (%dx%d and %dx%d)",
99 mp->n,mp->m,n,m);
100
101 dReal maxdiff;
102 if (lower_tri) {
103 maxdiff = dMaxDifferenceLowerTriangle (A,mp->data,n);
104 }
105 else {
106 maxdiff = dMaxDifference (A,mp->data,n,m);
107 }
108 if (maxdiff > tol)
109 dDebug (0,"dMatrixComparison, matrix error (size=%dx%d, name=\"%s\", "
110 "error=%.4e)",n,m,mi.name,maxdiff);
111 return maxdiff;
112 }
113}
114
115
116void dMatrixComparison::end()

Callers 3

dInternalStepIsland_x1Function · 0.80
dInternalStepIsland_x2Function · 0.80
dTestMatrixComparisonFunction · 0.80

Calls 6

dDebugFunction · 0.85
dAllocFunction · 0.85
dMaxDifferenceFunction · 0.85
pushMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected