\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 */
| 85 | * \return maximum absolute error between GT and estimate |
| 86 | */ |
| 87 | double MaxAbsError(const DataType TypeGT, |
| 88 | const SensorDataSet >, |
| 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 | } |
no test coverage detected