guten morgen,
ich habe ein problem, nämlich will ich meine eingabedaten aus einer datei, in eine vorgefertigte funktion einbinden, doch leider klappt dies nicht
würde mich freuen wenn mir da bitte jemand weiterhelfen kann.
gruß frank
hier der c++ quelltext:
#include <cstdlib>
#include <iostream>
#include <fstream>
#ifndef VITERBIS
#define VITERBIS
#define POLYA 0x6d
#define POLYB 0x4f
namespace SPUC {
#ifndef DOXYGEN_SHOULD_SKIP_THIS
class viterbi_state
{
public:
unsigned long path; /* Decoded path to this state */
long metric; /* Cumulative metric to this state */
};
#endif
class viterbi
{
public:
bool decoded;
bool enable_output;
bool output_ready;
long prev_value;
viterbi_state state0[64],state1[64],*state,*next;
int bitcnt;
int beststate;
long depuncture_bit_number;
bool phase;
viterbi() {
reset();
state = state0;
next = state1;
for(int i=0;i<64;i++) state[i].metric = -999999;
state[0].path = 0;
}
void reset() {
phase=0;
depuncture_bit_number=0;
decoded=1;
output_ready=0;
enable_output=0;
bitcnt=0;
prev_value=0;
beststate=0;
state = state0;
next = state1;
// Initialize starting metrics
// ...no longer prefer 0 state
for(int i=0;i<64;i++) {
state0[i].metric = -999999;
state1[i].metric = -999999;
state0[i].path = 0;
state1[i].path = 0;
}
}
bool clock(long value) {
bool z;
decoded = !decoded;
if (decoded) z = decode(prev_value,value);
prev_value = value;
if (enable_output) output_ready = decoded;
return(z);
}
bool decode(long s0, long s1);
void minimize_metrics() {
long bestmetric = state[beststate].metric;
for(int i=0;i<64;i++){
state[i].metric -= bestmetric;
}
}
bool depuncture(const long steal, long soft_in);
};
}
#endif
using namespace std;
int main(int argc, char *argv[])
{
string line;
ifstream myfile ("faltungscodierer2.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Datei kann nicht geoeffnet werden";
system("PAUSE");
return EXIT_SUCCESS;
}
hier der inhalt der datei:
0.000000000e+000
0.000000000e+000
1.000000000e+000
1.000000000e+000
0.000000000e+000
0.000000000e+000
0.000000000e+000
1.000000000e+000
0.000000000e+000
1.000000000e+000
0.000000000e+000
0.000000000e+000
1.000000000e+000
1.000000000e+000
1.000000000e+000
0.000000000e+000
0.000000000e+000
0.000000000e+000
0.000000000e+000
0.000000000e+000
0.000000000e+000
1.000000000e+000
0.000000000e+000
danke im vorraus