what is the primary expression in this case,

I am trying to use five functions in this program and it was working very well untill i introduced the functions into it but then it is saying missing primary expression before double i am not able to figure out what it is...


#include<iostream>
#include<math.h>
using namespace std;
int main ()
{
cout << "\n Errorcontrol_using_LDPC_coding by KRISHNA & NAYEEM \n\t";
// Defining the variables in the program
double X[4][8] = {};
double Y[4][8] = {};
int Z = 0;
int W = 0;
int H_matrix[4][8];
double sum;

// X = Messagefrom_Checks_to_Variables
// Y = Messagefrom_Variables_to_Checks
// Z = Present_Iteration_rate
// W = Intermediatevalue
int Maximum_no_of_iterations = 10;
int c[8] = {0, 0, 0, 0, 0, 0, 0, 0}; //c=msg*Ge
const int size =8;
int c_mod[size] = {};
cout << "\n\tInitail message codeword at transmitter side c=[0 0 0 0 0 0 0 0]\n";
// Codeword modulation
cout << "\n" ;
cout << "This is modulated codeword\n"; // Sice all the code word is included of zeros, so the o/p turns out to be negative values

cout << "\n" ;
int q =0;
for ( q = 0; q <= size-1; q = q + 1 )
if
(c[q] <= 0 && c[q] <= size ){ c_mod[q] = -1;}
else
{
c_mod[q] = 1;
}
for (int i=0; i<size ;i++)
cout<<i<<"\t"<<c_mod[i]<<endl;
cout << "\n" ;
int j,k;
//int H_matrix[4][8];//[4,8] = [n-k,n] for parity matrix, where k is the message length and n is the coded length
for (j = 0; j <= 3; j++)
for (k = 0; k <= 7; k++)
cin >> H_matrix[j][k];
// outputing the matrix
for (j = 0; j <= 3; j++)
{
for (k = 0; k <= 7; k++)
cout << H_matrix[j][k];
cout << endl;
}

//Recieved codeword through a noisy channel is given below

cout << "The recievd codeword is \n"; // Sice all the code word is included of zeros, so the o/p turns out to be negative values
cout << "\n" ;
double RCodeword[8] = {-2.5467, 0.2358, -1.3929, -3.0287, -1.8290, -1.1768, -1.9434, -0.1152};
int l,m;
for (l = 0; l <= 7; l++)
cout<<l<<"\t"<<RCodeword[l]<<endl;
cout << "\n" ;
// Step 1
double V[size] = {};
// V[m] = (( -2 * RCodeword )( N / 2 ) ^ 2); Since N =2, then V = - 2RCodeword
int g = 0;
for ( g = 0; g <= size-1; g = g + 1 )
V[g] = -2 * RCodeword [g];
for ( m =0; m <= 7; m++ )
cout << m<< "\t"<< V[m]<< endl;
//Step 2
for (int j = 0; j < 3; j++)
for (int k = 0; k< 7; k++)

H_matrix[j][k] = 0;
return X[j][k] = H_matrix [j][k];

Z = 1;
//Defining the function Second Stage

//return double SecondStage (int H_matrix, double V[g], double X, int Z );
//Y = double SecondStage(int H_matrix, double V[g],double X, int Z);

Y = double SecondStage(int H_matrix, double V[g], double X, int Z);

while
(((double ThirdStage(Y,Z) == 0) && (Z != Maximum_no_of_iterations)))
{
X = double FourthStage(H_matrix,Y,Z);
Z = Z + 1;
Y = SecondStage(H_matrix,V,X,Z);
}
double LastStage(V,X);
// Second stage defnition
return Y = double SecondStage(int H_matrix, double V[g], double X, int Z );
{
Y[j][k] = X [j][k];
for (q = 0; q <= 3; q++)
{for (int p = 0; p <= 7; p++)
{W = [: , p];
W[q]=[];
W = sum[W];
Y[q][p]=H_matrix[q][p]*(V[p]+W);
}
}
cout << "\n\n Result from the second stage(Iteration number = %d ) \n \t " ;
int i;
Y[4][8] = Y[j][k];
for (q = 1; q <=16; q++ )
cout << "\n\t From Variable %d to Check %d = %d\n\t ", j[q], k[q], Y[k[q]][j[q]] ;
}
// ThirdStage Defnition
int check_verification = double ThirdStage(Y,Z);
{
double satisfaction;
check_verification = 1;
cout << "\n\n\tRESULT FROM THIRDSTAGE(ITERATION NUMBER = %d )\n\t", Z ;
for (q = 1; q <= 4; q++)
W = Y[q,:];
if (W!=0);
satisfaction = W*2;
cout << "\n\tsatisfaction of Check %d = %d\n\t",q,satisfaction ;
if
(satisfaction < 0)
{
check_verification = 0;
}

}
// FourthSatge Definition
return X[4][8] = double FourthSatge(H_matrix, Y, Z);
{
for (j =0; j <= 3; j++)
for (k=0; k <= 7; k++)
Y[j][k] = 0;
X[j][k] = Y[j][k];
int p;
for (q = 1; q <= 8; q++)
for (int p = 1; p <= 4; p++)
W = Y[p,:];
W[q]=[];
W = tanh * (W/2);
if (W!=0);
W = W*2;
// Putting the tanh boundary limits for avoinding infinity case,took off sign in the 1st exp
if
(W < -0.9999 && W > 0.9999 ) { X[p][q] = H_matrix[p][q] * 2 * 5 * (atanh(W));}
else
{
X[p][q] = H_matrix[p][q]* 2 atanh(W);
}
cout << "\n\n\tRESULT FROM FOURTHSTAGE(ITERATION NUMBER = %d)\n\t", Z ;
int i;
X[4][8] = X[i][j];
for (q = 1; q <= 16; q++)
cout << "\n\tFrom Check %d to Variable %d = %d\n\t", i[q],j[q],X[i[q]][j[q]];
}
//LastStage Defnition
double output_final = double LastSatge(V,X)
{
output_final = V + sum(X,1);
cout << "\n\tFinal Result:\n\t\nV'={" ;
for (q = 1; q <= 7; q++ )
{
cout << "%d,\t", output_final [q];
}

cout << "\b\b}\n\t"
cout << "\n original codeword after demodulation is"
//final code display
if
(c = (output_final< 0))
cout << "c =[";
for (q =0; q <= 7; q++)
{cout << "%d, \t", c[q];
}
cout << "\b]\n\t";
//So the resulting message is first half of the codeword
cout << " Decoded Message is \t";
cout << "M = [";
for (q = 0; q <= 3; q++)
{cout << "%d,\t", c [q];
}
cout << "\b]\t"
}
return 0;
}







Last edited on
Y = double SecondStage(int H_matrix, double V[g], double X, int Z);

Not sure what do you want to do, but you can't do that.
I actually wanna run this program using five functions as defined below but it does not seem to work. Actually i have done the original in Matlab and trying to code it in c++ now. Thanks

#include<iostream>
#include<math.h>
using namespace std;
int main ()
{
cout << "\n Errorcontrol_using_LDPC_coding by KRISHNA & NAYEEM \n\t";
// Defining the variables in the program
double X[4][8] = {};
double Y[4][8] = {};
int Z = 0;
int W = 0;
int H_matrix[4][8];
double sum;

// X = Messagefrom_Checks_to_Variables
// Y = Messagefrom_Variables_to_Checks
// Z = Present_Iteration_rate
// W = Intermediatevalue
int Maximum_no_of_iterations = 10;
int c[8] = {0, 0, 0, 0, 0, 0, 0, 0}; //c=msg*Ge
const int size =8;
int c_mod[size] = {};
cout << "\n\tInitail message codeword at transmitter side c=[0 0 0 0 0 0 0 0]\n";
// Codeword modulation
cout << "\n" ;
cout << "This is modulated codeword\n"; // Sice all the code word is included of zeros, so the o/p turns out to be negative values

cout << "\n" ;
int q =0;
for ( q = 0; q <= size-1; q = q + 1 )
if
(c[q] <= 0){ c_mod[q] = -1;}
else
{
c_mod[q] = 1;
}
for (int i=0; i<size ;i++)
cout<<i<<"\t"<<c_mod[i]<<endl;
cout << "\n" ;
int j,k;
//int H_matrix[4][8];//[4,8] = [n-k,n] for parity matrix, where k is the message length and n is the coded length
for (j = 0; j <= 3; j++)
for (k = 0; k <= 7; k++)
cin >> H_matrix[j][k];
// outputing the matrix
for (j = 0; j <= 3; j++)
{
for (k = 0; k <= 7; k++)
cout << H_matrix[j][k];
cout << endl;
}

//Recieved codeword through a noisy channel is given below

cout << "The recievd codeword is \n"; // Sice all the code word is included of zeros, so the o/p turns out to be negative values
cout << "\n" ;
double RCodeword[8] = {-2.5467, 0.2358, -1.3929, -3.0287, -1.8290, -1.1768, -1.9434, -0.1152};
int l,m;
for (l = 0; l <= 7; l++)
cout<<l<<"\t"<<RCodeword[l]<<endl;
cout << "\n" ;
// Step 1
double V[size] = {};
// V[m] = (( -2 * RCodeword )( N / 2 ) ^ 2); Since N =2, then V = - 2RCodeword
int g = 0;
for ( g = 0; g <= size-1; g = g + 1 )
V[g] = -2 * RCodeword [g];
for ( m =0; m <= 7; m++ )
cout << m<< "\t"<< V[m]<< endl;
//Step 2
for (int j = 0; j < 3; j++)
for (int k = 0; k< 7; k++)

H_matrix[j][k] = 0;
return X[j][k] = H_matrix [j][k];

Z = 1;
//Defining the function Second Stage

return-double SecondStage (int H_matrix, double V[g], double X, int Z );
Y = SecondStage(H_matrix,V[g],X,Z);

// Y = double SecondStage(int H_matrix, double V[g], double X, int Z);

while
(((double ThirdStage(Y,Z) == 0) && (Z != Maximum_no_of_iterations)))
{
X = double FourthStage(H_matrix,Y,Z);
Z = Z + 1;
Y = SecondStage(H_matrix,V,X,Z);
}
double LastStage(V,X);
// Second stage defnition
return Y = double SecondStage(int H_matrix, double V[g], double X, int Z );
{
Y[j][k] = X [j][k];
for (q = 0; q <= 3; q++)
{for (int p = 0; p <= 7; p++)
{ W = [4][p];
W[q]=[];
W = sum[W];
Y[q][p]=H_matrix[q][p]*(V[p]+W);
}
}
cout << "\n\n Result from the second stage(Iteration number = %d ) \n \t " ;
int i;
Y[4][8] = Y[j][k];
for (q = 1; q <=16; q++ )
cout << "\n\t From Variable %d to Check %d = %d\n\t ", j[q], k[q], Y[k[q]][j[q]] ;
}
// ThirdStage Defnition
int check_verification = double ThirdStage(Y,Z);
{
double satisfaction;
check_verification = 1;
cout << "\n\n\tRESULT FROM THIRDSTAGE(ITERATION NUMBER = %d )\n\t", Z ;
for (q = 1; q <= 4; q++)
W = Y[q][8];
if (W!=0);
satisfaction = W*2;
cout << "\n\tsatisfaction of Check %d = %d\n\t",q,satisfaction ;
if
(satisfaction < 0)
{
check_verification = 0;
}

}
// FourthSatge Definition
return X[4][8] = double FourthSatge(H_matrix, Y, Z);
{
for (j =0; j <= 3; j++)
for (k=0; k <= 7; k++)
Y[j][k] = 0;
X[j][k] = Y[j][k];
int p;
for (q = 1; q <= 8; q++)
for (int p = 1; p <= 4; p++)
W = Y[p][8];
W[q]=[];
W = tanh * (W/2);
if (W!=0);
W = W*2;
// Putting the tanh boundary limits for avoinding infinity case,took off sign in the 1st exp
if
(W < -0.9999 && W > 0.9999 ) { X[p][q] = H_matrix[p][q] * 2 * 5 * (atanh(W));}
else
{
X[p][q] = H_matrix[p][q]* 2 atanh(W);
}
cout << "\n\n\tRESULT FROM FOURTHSTAGE(ITERATION NUMBER = %d)\n\t", Z ;
int i;
X[4][8] = X[i][j];
for (q = 1; q <= 16; q++)
cout << "\n\tFrom Check %d to Variable %d = %d\n\t", i[q],j[q],X[i[q]][j[q]];
}
//LastStage Defnition
double output_final = double LastSatge(V,X)
{
output_final = V + sum(X,1);
cout << "\n\tFinal Result:\n\t\nV'={" ;
for (q = 1; q <= 7; q++ )
{
cout << "%d,\t", output_final [q];
}

cout << "\b\b}\n\t"
cout << "\n original codeword after demodulation is"
//final code display
if
(c = (output_final< 0))
cout << "c =[";
for (q =0; q <= 7; q++)
{cout << "%d, \t", c[q];
}
cout << "\b]\n\t";
//So the resulting message is first half of the codeword
cout << " Decoded Message is \t";
cout << "M = [";
for (q = 0; q <= 3; q++)
{cout << "%d,\t", c [q];
}
cout << "\b]\t"
}
return 0;
}
Last edited on
Topic archived. No new replies allowed.