index Probleme



  • Wenn ich sowas errechne lasse:

    for(int i=1;i<7;i++){
    for(int i=0;j<zAnz;i++){
    for(int l=1;l<zAnz;l++){
    for(int k=1;k<iBase;k++){
    while(true){
    }
    int indx=zAnz*(2*i+i*iBase)+j;

    }
    }
    }
    }

    vergleiche soll und ist,wieso ist das so?????????

    für : zAnz | iBase | i | j ||indx(soll) || indx(ist)
    2 | 2 |1 |0 || 8 || 8
    2 | 2 |1 |1 || 9 || 9
    2 | 2 |2 |0 || 16 || 10
    2 | 2 |2 |1 || 17 || 11
    2 | 2 |3 |0 || 21 || 18
    2 | 2 |3 |1 || 25 || 19
    2 | 2 |4 |0 || 32 || 20
    2 | 2 |4 |1 || 33 || 21
    2 | 2 |5 |0 || 40 || 28
    2 | 2 |5 |1 || 41 || 29
    2 | 2 |6 |0 || 48 || 30
    2 | 2 |6 |1 || 49 || 31
    2 | 2 |7 |0 || 56 || 38
    2 | 2 |7 |1 || 57 || 39



  • Ich versteh zwar deine Frage nicht, aber in deinem Code hast du einmal wahrscheinlich i und j verwechselt («for(int i=0;j<zAnz;i++)»), und innen drin eine Endlosschleife.



  • Könnte jemand vielleicht helfen und mir sagen woran liegt´s das index werte siehe TABELLE unten falsch sind:

    [cpp][code][/code][/code][cpp]public:float* dynArray()
    {
    myArray = new float[eindringtiefe * zAnz * (2+iBase) ];

    for(int i=0;i<zAnz;i++ )
    {
    myArray[i]=1.0/zAnz;
    std::cout<<"myArray["<<i<<"] = "<<myArray[i]<<"für zstd: "<<i<<std::endl;
    }

    int* fuerfolgZstd; // Added
    Trellis* ptrel = new Trellis(trel);

    for(int i=1;i<eindringtiefe;i++)

    {
    //j entpricht dem aktuellen Zustand,der festzuhalten ist
    for(int j=0;j<zAnz;j++)
    {
    for(int l=0;l<zAnz;l++)
    {
    for(int k=0;k<iBase;k++)
    {
    fuerfolgZstd = ptrel->nextIntArray(l,k);
    int m=0;
    do{
    std::cout<<"ptrel->nIA: "<< ptrel->getZustand
    ()<<std::endl;
    int idxalpha =zAnz*(2*(i-1)+(i-1)iBase)+l;
    int idxgamma =zAnz
    (2*(i-1)+2+(i-1)iBase)
    +l
    iBase+k;
    std::cout<<"ALPHAS:myArray["<<idxalpha<<"]
    = "<<myArray[idxalpha]<<std::endl;
    std::cout<<"GAMMA:myArray["<<idxgamma<<"]
    = "<<myArray[idxgamma]<<std::endl;
    alpha+= myArray[idxalpha]*myArray[idxgamma];
    }while((j== ptrel->getZustand())&& (m++) &&
    (m=i-1));

    }
    }
    std::cout<<"zAnz: "<<zAnz<<"i: "<<i<<"iBase: "<<iBase<<"j: "<<j<<std::endl;
    int a=zAnz*2*i;
    int b=zAnz*i*iBase;
    hier------->int indx=(a+b+j);
    std::cout<<"I N D E X=zANZ*(2*i+i*iBase)
    +j:"<<indx<<std::endl;
    myArray[indx]=alpha;
    std::cout<<"alphas -->myArray["<<indx<<"] = "<< myArray
    [indx]<<std::endl;
    }
    std::cout<<"ALPHAS ZUM ZEITPUNKT: "<<i<<std::endl;
    }

    // G A M M A
    for(int i=0;i<eindringtiefe;i++)
    {
    //j entpricht dem aktuellen Zustand
    for(int j=0; j<zAnz+1; j++)
    {
    for(int k=0;k<iBase;k++)
    {

    float potenz=0.0;

    int* ausgangsdat = ptrel->nextIntArray(j,k);
    std::cout << "ptrel->nextIntArray(" << j << ", " << k
    << ");" << std::endl;
    //durchläuft die Anzahl der Ausgangssymbole
    for (int l=0;l<ptrel->getAusgangssymbolAnzahl();l++)
    {
    //nextDoble soll das vom Dekodierer eingelesene
    // Eingagssymbol darstellen
    //Annhame: dies geht mit vorBlock.nextfloat
    fftw_complex nextComplex;
    vorBlock.nextComplex( &nextComplex );
    //gibt den Wert aus Array ausgagngsdat am index l
    int ausgSymb = ausgangsdat[l];
    float f_ausgSymb = float(ausgSymb);
    //potenz+= fabs(nextfloat - f_ausgSymb)fabs(nextfloat -
    // f_ausgSymb);
    }
    float a = (0.5/(sqrt(2*pi)*sigma(0)));
    float exponent = (-0.5)*potenz/(sigma( 0)*sigma(0));
    float b = exp(exponent);
    gamma = a * b;
    int idx = zAnz
    (2*i+2+i*iBase)+j*iBase+k;
    std::cout << "Gamma[ "<< idx << " ]= " << gamma <<
    std::endl;
    myArray[ idx ]=gamma;
    }
    }
    [/cpp][code][/cpp]

    [i]hier oben nochmal etwas ausführlicher, hab selber schon geschaut seh den fehler aber nicht.

    d.h.: anstatt
    -------------------------------------------------------------------------------

    für : zAnz | iBase | i | j ||indx(soll) || indx(ist)
    2 | 2 |1 |0 || 8 || 8
    2 | 2 |1 |1 || 9 || 9
    2 | 2 |2 |0 || 16 || 10
    2 | 2 |2 |1 || 17 || 11
    2 | 2 |3 |0 || 21 || 18
    2 | 2 |3 |1 || 25 || 19
    2 | 2 |4 |0 || 32 || 20
    2 | 2 |4 |1 || 33 || 21
    2 | 2 |5 |0 || 40 || 28
    2 | 2 |5 |1 || 41 || 29
    2 | 2 |6 |0 || 48 || 30
    2 | 2 |6 |1 || 49 || 31
    2 | 2 |7 |0 || 56 || 38
    2 | 2 |7 |1 || 57 || 39

    Danke


Anmelden zum Antworten