Code translation (#1626)

* comment translation

* translation part #2

* code translation from DE to ENG #part3

* translation #4

* dismantled =>splitted

* bereich => range

* Update defines.h

Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com>
This commit is contained in:
Nicolas Liaudat
2022-12-19 22:05:45 +01:00
committed by GitHub
parent 67ff06f64e
commit f6369ff237
31 changed files with 686 additions and 750 deletions

View File

@@ -0,0 +1,104 @@
#include <unity.h>
#include <ClassFlowCNNGeneral.h>
class UnderTestCNNGeneral : public ClassFlowCNNGeneral {
public:
UnderTestCNNGeneral( ClassFlowAlignment *_flowalign, t_CNNType _cnntype) :
ClassFlowCNNGeneral(_flowalign, _cnntype) {};
using ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew;
};
/**
* @brief
*
* Transition = x.8 - x.2 here no transition in the test cases.
* Offset = dig=x.n, ana= n.y: no offset, because both "n" are the same
*/
void test_analogToDigit_Standard() {
UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100);
// 4.8 is a "hanging" 5, i.e. it has not jumped over to 5.0.
// A "hanging digit" should still be rounded from Transition.
// Transition = yes
// Offset = no
TEST_ASSERT_EQUAL_INT(5, undertest->PointerEvalAnalogToDigitNew(4.8, 8.0, 8, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issue-1344032217
// Default: dig=9.6, ana=6.8 => erg=9
// Transition = no
// Offset = no
TEST_ASSERT_EQUAL_INT(9, undertest->PointerEvalAnalogToDigitNew( 9.6, 6.8, 6, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1220365920
// Default: dig=4.6, ana=6.2 => erg=4
// Transition = no
// Offset = no
TEST_ASSERT_EQUAL_INT(4, undertest->PointerEvalAnalogToDigitNew( 4.6, 6.2, 6, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
// Hanging digit ()
// Default: dig=6.8, ana=8.6 => erg=7
// Transition = no
// Offset = no
TEST_ASSERT_EQUAL_INT(7, undertest->PointerEvalAnalogToDigitNew( 6.8, 8.6, 6, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
// Also hanging digit () with small pointer after 0 pass.
// Default: dig=6.8, ana=1.0 => erg=7
// Transition = no
// Offset = no
TEST_ASSERT_EQUAL_INT(7, undertest->PointerEvalAnalogToDigitNew( 6.8, 1.0, 1, 9.2));
}
void test_analogToDigit_Transition() {
UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100);
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1222672175
// Default: dig=3.9, ana=9.7 => erg=3
// Transition = yes
// Zero crossing = no
// Offset = no
TEST_ASSERT_EQUAL_INT(3, undertest->PointerEvalAnalogToDigitNew( 3.9, 9.7, 9, 9.2));
// without reference
// Default: dig=4.0, ana=9.1 => erg=4
// Transition = yes
// Zero crossing = no
// Offset = no
// Special feature: Digit has not yet started at analogue 9.1
TEST_ASSERT_EQUAL_INT(4, undertest->PointerEvalAnalogToDigitNew( 4.0, 9.1, 9, 9.2));
// without reference
// Default: dig=9.8, ana=0.1, ana_2=9.9 => erg=9
// transition = yes
// Zero crossing = no
// Offset = no
// Special feature: analogue is set back to 9 by previous analogue
TEST_ASSERT_EQUAL_INT(9, undertest->PointerEvalAnalogToDigitNew( 9.8, 0.1, 9, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1277425333
// Default: dig=5.9, ana=9.4 => erg=9
// Transition = yes
// Zero crossing = no
// Offset = no
// Special feature:
TEST_ASSERT_EQUAL_INT(5, undertest->PointerEvalAnalogToDigitNew( 5.9, 9.4, 9, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030
// Default: dig=1.8, ana=7.8 => erg=9
// Transition = yes
// Zero crossing = no
// Offset = no
// Special feature: Digit runs with analogue. Therefore 1.8 (vs. 7.8)
TEST_ASSERT_EQUAL_INT(1, undertest->PointerEvalAnalogToDigitNew( 1.8, 7.8, 7, 7.7));
}

View File

@@ -1,104 +0,0 @@
#include <unity.h>
#include <ClassFlowCNNGeneral.h>
class UnderTestCNNGeneral : public ClassFlowCNNGeneral {
public:
UnderTestCNNGeneral( ClassFlowAlignment *_flowalign, t_CNNType _cnntype) :
ClassFlowCNNGeneral(_flowalign, _cnntype) {};
using ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu;
};
/**
* @brief
*
* Transition = x.8 - x.2 hier keine Transition in den Testfaellen
* Versatz = dig=x.n, ana= n.y: kein Versatz, da beide "n" gleich
*/
void test_analogToDigit_Standard() {
UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100);
// 4.8 ist eine "hängende" 5. Heißt sie ist nicht bis auf 5.0 umgesprungen.
// ab Transition sollte trotzdem ein "hängendes Digit" gerundet werden.
// Transition = ja
// Versatz = nein
TEST_ASSERT_EQUAL_INT(5, undertest->ZeigerEvalAnalogToDigitNeu(4.8, 8.0, 8, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issue-1344032217
// Standard: dig=9.6, ana=6.8 => erg=9
// Transition = nein
// Versatz = nein
TEST_ASSERT_EQUAL_INT(9, undertest->ZeigerEvalAnalogToDigitNeu( 9.6, 6.8, 6, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1220365920
// Standard: dig=4.6, ana=6.2 => erg=4
// Transition = nein
// Versatz = nein
TEST_ASSERT_EQUAL_INT(4, undertest->ZeigerEvalAnalogToDigitNeu( 4.6, 6.2, 6, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
// Hängendes digit ()
// Standard: dig=6.8, ana=8.6 => erg=7
// Transition = nein
// Versatz = nein
TEST_ASSERT_EQUAL_INT(7, undertest->ZeigerEvalAnalogToDigitNeu( 6.8, 8.6, 6, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
// Ebenfalls Hängendes digit () bei kleinem Zeiger nach 0-Durchlauf
// Standard: dig=6.8, ana=1.0 => erg=7
// Transition = nein
// Versatz = nein
TEST_ASSERT_EQUAL_INT(7, undertest->ZeigerEvalAnalogToDigitNeu( 6.8, 1.0, 1, 9.2));
}
void test_analogToDigit_Transition() {
UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100);
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1222672175
// Standard: dig=3.9, ana=9.7 => erg=3
// Transition = ja
// Nulldurchgang = nein
// Versatz = nein
TEST_ASSERT_EQUAL_INT(3, undertest->ZeigerEvalAnalogToDigitNeu( 3.9, 9.7, 9, 9.2));
// ohne Referenz
// Standard: dig=4.0, ana=9.1 => erg=4
// Transition = ja
// Nulldurchgang = nein
// Versatz = nein
// Besonderheit: Digit ist bei analog 9.1 noch nicht losgelaufen
TEST_ASSERT_EQUAL_INT(4, undertest->ZeigerEvalAnalogToDigitNeu( 4.0, 9.1, 9, 9.2));
// ohne Referenz
// Standard: dig=9.8, ana=0.1, ana_2=9.9 => erg=9
// Transition = ja
// Nulldurchgang = nein
// Versatz = nein
// Besonderheit: analog wird durch vorherigen analog wieder auf 9 gesetzt
TEST_ASSERT_EQUAL_INT(9, undertest->ZeigerEvalAnalogToDigitNeu( 9.8, 0.1, 9, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1277425333
// Standard: dig=5.9, ana=9.4 => erg=9
// Transition = ja
// Nulldurchgang = nein
// Versatz = nein
// Besonderheit:
TEST_ASSERT_EQUAL_INT(5, undertest->ZeigerEvalAnalogToDigitNeu( 5.9, 9.4, 9, 9.2));
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030
// Standard: dig=1.8, ana=7.8 => erg=9
// Transition = ja
// Nulldurchgang = nein
// Versatz = nein
// Besonderheit: Digit läuft mit Analog mit. Deshalb 1.8 (vs. 7.8)
TEST_ASSERT_EQUAL_INT(1, undertest->ZeigerEvalAnalogToDigitNeu( 1.8, 7.8, 7, 7.7));
}

View File

@@ -3,8 +3,8 @@
class UnderTestCNN : public ClassFlowCNNGeneral {
public:
using ClassFlowCNNGeneral::ZeigerEvalAnalogNeu;
using ClassFlowCNNGeneral::ZeigerEvalHybridNeu;
using ClassFlowCNNGeneral::PointerEvalAnalogNew;
using ClassFlowCNNGeneral::PointerEvalHybridNew;
using ClassFlowCNNGeneral::ClassFlowCNNGeneral;
};
@@ -20,21 +20,21 @@ void test_ZeigerEval()
// the 5.2 is already above 5.0 and the previous digit too (3)
printf("Test 5.2, 3\n");
int result = undertest.ZeigerEvalAnalogNeu(5.2, 3);
int result = undertest.PointerEvalAnalogNew(5.2, 3);
TEST_ASSERT_EQUAL(5, result);
// the 5.2 is already above 5.0 and the previous digit not (9)
// so the current digit shoult be reduced (4.9)
printf("Test 5.2, 9\n");
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalAnalogNeu(5.2, 9));
TEST_ASSERT_EQUAL(4, undertest.PointerEvalAnalogNew(5.2, 9));
printf("Test 4.4, 9\n");
// the 4.4 (digital100) is not above 5 and the previous digit (analog) too (9.3)
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalAnalogNeu(4.4, 9));
TEST_ASSERT_EQUAL(4, undertest.PointerEvalAnalogNew(4.4, 9));
printf("Test 4.5, 0\n");
// the 4.5 (digital100) is not above 5 and the previous digit (analog) too (9.6)
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalAnalogNeu(4.5, 0));
TEST_ASSERT_EQUAL(4, undertest.PointerEvalAnalogNew(4.5, 0));
}
@@ -46,57 +46,57 @@ void test_ZeigerEvalHybrid() {
UnderTestCNN undertest = UnderTestCNN(nullptr, Digital100);
// the 5.2 and no previous should round down
printf("ZeigerEvalHybridNeu(5.2, 0, -1)\n");
TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.2, 0, -1));
printf("PointerEvalHybridNew(5.2, 0, -1)\n");
TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.2, 0, -1));
// the 5.3 and no previous should trunc to 5
printf("ZeigerEvalHybridNeu(5.3, 0, -1)\n");
TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.3, 0, -1));
printf("PointerEvalHybridNew(5.3, 0, -1)\n");
TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.3, 0, -1));
printf("ZeigerEvalHybridNeu(5.7, 0, -1)\n");
printf("PointerEvalHybridNew(5.7, 0, -1)\n");
// the 5.7 and no previous should trunc to 5
TEST_ASSERT_EQUAL(6, undertest.ZeigerEvalHybridNeu(5.7, 0, -1));
TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.7, 0, -1));
// the 5.8 and no previous should round up to 6
printf("ZeigerEvalHybridNeu(5.8, 0, -1)\n");
TEST_ASSERT_EQUAL(6, undertest.ZeigerEvalHybridNeu(5.8, 0, -1));
printf("PointerEvalHybridNew(5.8, 0, -1)\n");
TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.8, 0, -1));
// the 5.7 with previous and the previous between 0.3-0.5 should round up to 6
TEST_ASSERT_EQUAL(6, undertest.ZeigerEvalHybridNeu(5.7, 0.4, 1));
TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.7, 0.4, 1));
// the 5.3 with previous and the previous between 0.3-0.7 should round down to 5
TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.3, 0.7, 1));
TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.3, 0.7, 1));
// the 5.3 with previous and the previous <=0.5 should trunc to 5
TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.3, 0.1, 1));
TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.3, 0.1, 1));
// the 5.3 with previous and the previous >=9.5 should reduce to 4
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(5.3, 9.6, 9));
TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(5.3, 9.6, 9));
// the 5.7 with previous and the previous >=9.5 should trunc to 5
TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybridNeu(5.7, 9.6, 9));
TEST_ASSERT_EQUAL(5, undertest.PointerEvalHybridNew(5.7, 9.6, 9));
// the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.6)
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(4.5, 9.6, 0));
TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.5, 9.6, 0));
// the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.6)
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(4.5, 9.6, 9));
TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.5, 9.6, 9));
// the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5)
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(4.5, 9.5, 9));
TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.5, 9.5, 9));
// 59.96889 - Pre: 58.94888
// 8.6 : 9.8 : 6.7
// the 4.4 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5)
TEST_ASSERT_EQUAL(8, undertest.ZeigerEvalHybridNeu(8.6, 9.8, 9));
TEST_ASSERT_EQUAL(8, undertest.PointerEvalHybridNew(8.6, 9.8, 9));
// pre = 9.9 (0.0 raw)
// zahl = 1.8
TEST_ASSERT_EQUAL(2, undertest.ZeigerEvalHybridNeu(1.8, 9.0, 9));
TEST_ASSERT_EQUAL(2, undertest.PointerEvalHybridNew(1.8, 9.0, 9));
// if a digit have an early transition and the pointer is < 9.0
// prev (pointer) = 6.2, but on digital readout = 6.0 (prev is int parameter)
// zahl = 4.6
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybridNeu(4.6, 6.0, 6));
TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.6, 6.0, 6));
// issue #879 vorgaenger is -1, zahl = 6.7