MCPcopy Create free account
hub / github.com/TUC-ProAut/libRSF / MaxAbsError

Function MaxAbsError

test/TestUtils.cpp:87–136  ·  view source on GitHub ↗

\brief maximum componentwise absolute difference between two datasets (mean and covariance) * * \param TypeGT the type of the GT data * \param GT a data set that holds the GT * \param TypeEstimate type of the estimate * \param Estimate data set that holds the estimation * \return maximum absolute error between GT and estimate */

Source from the content-addressed store, hash-verified

85 * \return maximum absolute error between GT and estimate
86 */
87 double MaxAbsError(const DataType TypeGT,
88 const SensorDataSet &GT,
89 const std::string &TypeEstimate,
90 const StateDataSet &Estimate,
91 const DataElement Element)
92 {
93 /** check length */
94 const int LengthGT = GT.countElements(TypeGT);
95 const int LengthEstimate = Estimate.countElements(TypeEstimate);
96
97 /** return error if not equal */
98 if (LengthGT != LengthEstimate)
99 {
100 PRINT_ERROR("Length of GT and estimate is not identical!");
101 return std::numeric_limits<double>::quiet_NaN();
102 }
103
104 /** initialize maximum error */
105 double maxAbsError = 0;
106
107 /** get first timestamp */
108 double Time = 0.0;
109 GT.getTimeFirst(TypeGT, Time);
110
111 /** calculate overall maximum */
112 do
113 {
114 int NumberOfStates = GT.countElement(TypeGT,Time);
115 for (int nState = 0; nState < NumberOfStates; ++nState)
116 {
117 /** get data at this timestamp */
118 Data DataGT, DataEstimate;
119 Estimate.getElement(TypeEstimate, Time, nState, DataEstimate);
120 GT.getElement(TypeGT, Time, nState, DataGT);
121
122 /** get maximum difference */
123 const double maxAbsErrorTmp = (DataEstimate.getValue(Element) - DataGT.getValue(Element)).cwiseAbs().maxCoeff();
124
125 /** store maximum of loop */
126 if(maxAbsErrorTmp > maxAbsError)
127 {
128 maxAbsError = maxAbsErrorTmp;
129 }
130 }
131 }
132 while(GT.getTimeNext(TypeGT, Time, Time));
133
134 /** return overall maximum */
135 return maxAbsError;
136 }
137}

Callers 6

TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85

Calls 6

countElementsMethod · 0.80
countElementMethod · 0.80
getElementMethod · 0.80
getValueMethod · 0.80
getTimeNextMethod · 0.80
getTimeFirstMethod · 0.45

Tested by

no test coverage detected