#604 fix
This commit is contained in:
parent
e2c1cc91ad
commit
52ab8424e7
|
@ -78,8 +78,14 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
|
||||||
if (needInterpolationLogging())
|
if (needInterpolationLogging())
|
||||||
printf("Y is smaller than smallest cell in table: %d\r\n", yIndex);
|
printf("Y is smaller than smallest cell in table: %d\r\n", yIndex);
|
||||||
#endif /* DEBUG_INTERPOLATION */
|
#endif /* DEBUG_INTERPOLATION */
|
||||||
// no interpolation should be fine here.
|
if (xIndex == xBinSize - 1)
|
||||||
return map[xIndex][0];
|
return map[xIndex][0];
|
||||||
|
float key1 = xBin[xIndex];
|
||||||
|
float key2 = xBin[xIndex + 1];
|
||||||
|
float value1 = map[xIndex][0];
|
||||||
|
float value2 = map[xIndex + 1][0];
|
||||||
|
|
||||||
|
return interpolateMsg("out3d", key1, value1, key2, value2, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xIndex == xBinSize - 1 && yIndex == yBinSize - 1) {
|
if (xIndex == xBinSize - 1 && yIndex == yBinSize - 1) {
|
||||||
|
@ -95,8 +101,14 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
|
||||||
if (needInterpolationLogging())
|
if (needInterpolationLogging())
|
||||||
printf("TODO BETTER LOGGING x overflow %d\r\n", yIndex);
|
printf("TODO BETTER LOGGING x overflow %d\r\n", yIndex);
|
||||||
#endif /* DEBUG_INTERPOLATION */
|
#endif /* DEBUG_INTERPOLATION */
|
||||||
// todo: implement better handling - y interpolation
|
// here yIndex is less than yBinSize - 1, we've checked that condition already
|
||||||
return map[xBinSize - 1][yIndex];
|
|
||||||
|
float key1 = yBin[yIndex];
|
||||||
|
float key2 = yBin[yIndex + 1];
|
||||||
|
float value1 = map[xIndex][yIndex];
|
||||||
|
float value2 = map[xIndex][yIndex + 1];
|
||||||
|
|
||||||
|
return interpolateMsg("out3d", key1, value1, key2, value2, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yIndex == yBinSize - 1) {
|
if (yIndex == yBinSize - 1) {
|
||||||
|
@ -104,8 +116,14 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
|
||||||
if (needInterpolationLogging())
|
if (needInterpolationLogging())
|
||||||
printf("Y is larger than largest cell in table: %d\r\n", yIndex);
|
printf("Y is larger than largest cell in table: %d\r\n", yIndex);
|
||||||
#endif /* DEBUG_INTERPOLATION */
|
#endif /* DEBUG_INTERPOLATION */
|
||||||
// todo: implement better handling - x interpolation
|
// here xIndex is less than xBinSize - 1, we've checked that condition already
|
||||||
return map[xIndex][yBinSize - 1];
|
|
||||||
|
float key1 = xBin[xIndex];
|
||||||
|
float key2 = xBin[xIndex + 1];
|
||||||
|
float value1 = map[xIndex][yIndex];
|
||||||
|
float value2 = map[xIndex + 1][yIndex];
|
||||||
|
|
||||||
|
return interpolateMsg("out3d", key1, value1, key2, value2, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -733,5 +733,5 @@ int getRusEfiVersion(void) {
|
||||||
if (initBootloader() != 0)
|
if (initBootloader() != 0)
|
||||||
return 123;
|
return 123;
|
||||||
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
||||||
return 20180808;
|
return 20180819;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,50 +61,54 @@ static void newTestToComfirmInterpolation() {
|
||||||
assertEqualsM("middle cell ", 54.25, getValue(/*rpm*/250, 2.5));
|
assertEqualsM("middle cell ", 54.25, getValue(/*rpm*/250, 2.5));
|
||||||
|
|
||||||
// issue #604: interpolation outside of the table
|
// issue #604: interpolation outside of the table
|
||||||
assertEqualsM("800 @ 2.1 ",200, getValue(/*rpm*/800, 2.1));
|
// X above the range
|
||||||
assertEqualsM("800 @ 2.3 ",200, getValue(/*rpm*/800, 2.3));
|
assertEqualsM("800 @ 2.1 ",230, getValue(/*rpm*/800, 2.1));
|
||||||
assertEqualsM("800 @ 3.3 ",500, getValue(/*rpm*/800, 3.3));
|
assertEqualsM("800 @ 2.3 ",290, getValue(/*rpm*/800, 2.3));
|
||||||
|
assertEqualsM("800 @ 3.3 ",530, getValue(/*rpm*/800, 3.3));
|
||||||
|
|
||||||
|
// X below the range
|
||||||
|
assertEqualsM("-810 @ 2.1 ",2.1, getValue(/*rpm*/-810, 2.1));
|
||||||
|
assertEqualsM("-820 @ 2.3 ",2.3, getValue(/*rpm*/-820, 2.3));
|
||||||
|
|
||||||
|
// Y above the range
|
||||||
|
assertEqualsM("310 @ 12.1 ", 330, getValue(/*rpm*/310, 12.1));
|
||||||
|
assertEqualsM("320 @ 12.3 ", 360, getValue(/*rpm*/320, 12.3));
|
||||||
|
|
||||||
|
// Y below the range
|
||||||
|
assertEqualsM("310 @ -12.1 ", 3.1, getValue(/*rpm*/310, -12.1));
|
||||||
|
assertEqualsM("320 @ -12.3 ", 3.2, getValue(/*rpm*/320, -12.3));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testInterpolate3d(void) {
|
void testInterpolate3d(void) {
|
||||||
printf("*************************************************** testInterpolate3d\r\n");
|
printf("*************************************************** testInterpolate3d\r\n");
|
||||||
float dwell;
|
|
||||||
printf("*** no interpolation here 1\r\n");
|
printf("*** no interpolation here 1\r\n");
|
||||||
dwell = getValue(100, 2);
|
assertEquals(2, getValue(100, 2));
|
||||||
assertEquals(2, dwell);
|
|
||||||
|
|
||||||
printf("*** no interpolation here 2\r\n");
|
printf("*** no interpolation here 2\r\n");
|
||||||
dwell = getValue(200, 4);
|
assertEquals(5, getValue(200, 4));
|
||||||
assertEquals(5, dwell);
|
|
||||||
|
|
||||||
printf("*** rpm interpolated value expected1\r\n");
|
printf("*** rpm interpolated value expected1\r\n");
|
||||||
dwell = getValue(150, 2);
|
assertEquals(2.5, getValue(150, 2));
|
||||||
assertEquals(2.5, dwell);
|
|
||||||
|
|
||||||
printf("*** rpm interpolated value expected2\r\n");
|
printf("*** rpm interpolated value expected2\r\n");
|
||||||
dwell = getValue(250, 3);
|
assertEquals(102, getValue(250, 3));
|
||||||
assertEquals(102, dwell);
|
|
||||||
|
|
||||||
printf("*** both rpm and maf interpolated value expected\r\n");
|
printf("*** both rpm and maf interpolated value expected\r\n");
|
||||||
dwell = getValue(335.3, 3.551);
|
assertEquals(361, getValue(335.3, 3.551));
|
||||||
assertEquals(361, dwell);
|
|
||||||
|
|
||||||
printf("*** both rpm and maf interpolated value expected 2\r\n");
|
printf("*** both rpm and maf interpolated value expected 2\r\n");
|
||||||
dwell = getValue(410.01, 2.012);
|
assertEquals(203.6, getValue(410.01, 2.012));
|
||||||
assertEquals(203.6, dwell);
|
|
||||||
|
|
||||||
printf("*** both rpm and maf interpolated value expected 3\r\n");
|
printf("*** both rpm and maf interpolated value expected 3\r\n");
|
||||||
dwell = getValue(1000000, 1000);
|
assertEquals(600, getValue(1000000, 1000));
|
||||||
assertEquals(600, dwell);
|
|
||||||
|
|
||||||
printf("*** both rpm and maf interpolated value expected 4\r\n");
|
printf("*** both rpm and maf interpolated value expected 4\r\n");
|
||||||
dwell = getValue(410.01, -1);
|
|
||||||
assertEquals(4, dwell);
|
|
||||||
|
|
||||||
dwell = getValue(-1, -1);
|
assertEquals(4, getValue(410.01, -1));
|
||||||
assertEquals(1, dwell);
|
|
||||||
|
|
||||||
|
assertEquals(1, getValue(-1, -1));
|
||||||
|
|
||||||
newTestToComfirmInterpolation();
|
newTestToComfirmInterpolation();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue