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++)
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++)