Ejemplo n.º 1
0
std::vector<int> QAMDecoder::decode(std::vector<double> phase,
		std::vector<double> quad, double n0) {
	if (phase.size() != quad.size() || phase.size() != s) {
		std::stringstream str;
		str << "Invalid input size";
		throw std::invalid_argument(str.str());
	}

	//LLR symbol node initialization
	for (int i = 0; i < s; i++) {
		//TODO fix initialization
		received.at(i)->setValue(phase.at(i), quad.at(i));
		if (DEBUG) {
			std::cout << phase.at(i) << " " << quad.at(i) << " ";
		}
	}
	if (DEBUG) {
		std::cout << " received\n";
	}

	//Message passing (stops when Hc=0 or after a max number of cycles)
	int pass = 0;
	bool check = parityCheck();
	while (!check && pass < passes) {
		forwardPassing();
		if (DEBUG) {
			for (int i = 0; i < k; i++) {
				std::cout << parity.at(i)->getValue() << " ";
			}
			std::cout << "LLR (check)\n";
		}
		check = parityCheck();
		if (check) {
			break;
		}
		backwardPassing();
		if (DEBUG) {
			for (int i = 0; i < n; i++) {
				std::cout << encoded.at(i)->getValue() << " ";
			}
			std::cout << "LLR (var)\n";
		}
		check = parityCheck();
		pass += 2;
	}

	//Decoded vector
	std::vector<int> decoded;
	for (int i = 0; i < n; i++) {
		double in = encoded.at(i)->getValue();
		decoded.push_back(encoded.at(i)->llr2val(in));
	}
	resetGraph();

	return decoded;
}
Ejemplo n.º 2
0
std::vector<int> LDPCDecoder::decode(std::vector<double> llr) {
	if (n != llr.size()) {
		std::stringstream str;
		str << "Invalid input size";
		throw std::invalid_argument(str.str());
	}

	//LLR variable node initialization
	for (int i = 0; i < n; i++) {
		received.at(i)->setValue(llr.at(i));
		if (DEBUG) {
			std::cout << llr.at(i) << " ";
		}
	}
	if (DEBUG) {
		std::cout << " LLR\n";
	}

	//Message passing (stops when Hc=0 or after a max number of cycles)
	int pass = 0;
	bool check = parityCheck();
	while (!check && pass < passes) {
		forwardPassing();
		if (DEBUG) {
			for (int i = 0; i < k; i++) {
				std::cout << parity.at(i)->getValue() << " ";
			}
			std::cout << "LLR (check)\n";
		}
		backwardPassing();
		if (DEBUG) {
			for (int i = 0; i < n; i++) {
				std::cout << received.at(i)->getValue() << " ";
			}
			std::cout << "LLR (var)\n";
		}
		check = parityCheck();
		pass += 2;
	}

	//Decoded vector
	std::vector<int> decoded;
	for (int i = 0; i < n; i++) {
		double in = received.at(i)->getValue();
		decoded.push_back(received.at(i)->llr2val(in));
	}
	resetGraph();

	return decoded;
}
Ejemplo n.º 3
0
int main() {
    int parity;
    parity = parityCheck(35, 6);
    printf("parity check result is %d\n", parity);

    return 0;
}
Ejemplo n.º 4
0
int ImagerDoc::parity_check(void * in ){

  char *c = (char*) in;
  int j=0;
  int a[6] = {    0,  278, 1626, 2306, 5386, 6304};
  int b[6] = {  277, 1625, 2305, 5385, 6303, 8039};

  // default everything is bad
  int iss_status = 126; //bits 1-7 on

  for (j=0; j<6; j++) {
    if (  parityCheck(c+a[j], b[j]-a[j]) == *(c+b[j])  )  {
       iss_status -= (2 << j); // set bit flag for this section to 0 to indicate it's good
       //memcpy(&Spcid+a[j], c+a[j], b[j]-a[j]+1);
    }
  }

  return(iss_status);
}
Ejemplo n.º 5
0
std::vector<int> LDPCDecoder::decode(std::vector<double> llr,
		boost::numeric::ublas::matrix<double> &errors, int counter,
		std::vector<int> uncoded) {
	if (n != llr.size()) {
		std::stringstream str;
		str << "Invalid input size";
		throw std::invalid_argument(str.str());
	}

	//LLR variable node initialization
	for (int i = 0; i < n; i++) {
		received.at(i)->setValue(llr.at(i));
		if (DEBUG) {
			std::cout << llr.at(i) << " ";
		}
	}
	if (DEBUG) {
		std::cout << " LLR\n";
	}

	//Message passing (stops when Hc=0 or after a max number of cycles)
	int pass = 0;
	bool check = false; //parityCheck();
	while (!check && pass < passes) {
		forwardPassing();
		if (DEBUG) {
			for (int i = 0; i < k; i++) {
				std::cout << parity.at(i)->getValue() << " ";
			}
			std::cout << "LLR (check)\n";
		}
		backwardPassing();
		if (DEBUG) {
			for (int i = 0; i < n; i++) {
				std::cout << received.at(i)->getValue() << " ";
			}
			std::cout << "LLR (var)\n";
		}
		//check = parityCheck();
		pass += 2;

		if (!parityCheck()) {
			errors(counter, pass / 2)++;

			}
		else {
			for (int i = 0; i < k; i++) {
				double in = received.at(i)->getValue();
				if (received.at(i)->llr2val(in) != uncoded.at(i)) {
					errors(counter, pass / 2)++;break
;				}
			}
		}
		errors(0, 0)++;}

		//Decoded vector
	std::vector<int> decoded;
	for (int i = 0; i < n; i++) {
		double in = received.at(i)->getValue();
		decoded.push_back(received.at(i)->llr2val(in));
	}
	resetGraph();

	return decoded;
}