Example #1
0
void evaluate_error(unsigned int *error_magnitudes, 
			unsigned int *error_locator_poly_derivative, 
			unsigned int *error_evaluator_poly, 
			unsigned int *locators, 
			int length_of_locators){
	int i = 0, j = 0, k = 0;
	unsigned int poly_evaluation = 0;
	unsigned int power = 1;
	unsigned int inverse_locator = 0 ;
	int temp = 0;// temp is the power of locator[i], also the error location,
	//ranges from 1 to N 

	for(i = 0; i < length_of_locators; i++){
		inverse_locator = galois_inverse(locators[i], w);
		//nominator computing
		poly_evaluation = 0;		
		for(j = N - 1; j >= K - 1; j--){//?
			power = 1;
			for(k = 0; k < N - 1 - j; k++)
				power = galois_single_multiply(power, inverse_locator, w);
			poly_evaluation ^= galois_single_multiply(power, error_evaluator_poly[j], w); 
		//	printf("test %d	\n", poly_evaluation);
		}		
		error_magnitudes[i] = galois_single_multiply(poly_evaluation, locators[i], w);
		//denominator computing
		poly_evaluation = 0;
		for(j = (N - K)/2; j >= 0; j--){
			power = 1;
			for(k = 0; k < (N - K)/2 - j; k++)
				power = galois_single_multiply(power, inverse_locator, w);
			poly_evaluation ^= galois_single_multiply(power, error_locator_poly_derivative[j], w); 
		}
		// error magnitudes  computing		
		error_magnitudes[i] = galois_single_divide(error_magnitudes[i], poly_evaluation, w);
		//if decode GRS, then we will have to divide error_magnitudes by parity
		//check matrix's corresponding column multipliers, otherwise we have to
		//comment this function or set multipliers vector to all ones.
		temp = galois_log(locators[i], w);

		error_magnitudes[i] = galois_single_divide(error_magnitudes[i],
		                                            multiplier[temp], w);
	}
	printf("The error magnitudes are:\n");
	for(i = 0; i < length_of_locators; i ++){
		printf("%d	", error_magnitudes[i]);
	}
	printf("\n");
}
Example #2
0
main(int argc, char **argv)
{
  unsigned int x, w;

  if (argc != 3) {
    fprintf(stderr, "usage: gf_log x w - returns the discrete log if x in GF(2^w)\n");
    exit(1);
  }

  sscanf(argv[1], "%u", &x);
  w = atoi(argv[2]);

  if (w < 1 || w > 32) { fprintf(stderr, "Bad w\n"); exit(1); }

  if (x == 0 || (w < 32 && x >= (1 << w))) { fprintf(stderr, "x must be in [1,%d]\n", (1 << w)-1); exit(1); }

  printf("%u\n", galois_log(x, w));
  exit(0);
}
Example #3
0
void rsdecode(unsigned int *locators, unsigned int *received_codeword){
	unsigned int syndrome[N - K] = {0};
	unsigned int error_locator_poly[(N - K)/2 + 1] = {0};
	unsigned int error_locator_poly_derivative[(N - K)/2 + 1] = {0};
	unsigned int error_evaluator_poly[N] = {0};
	unsigned int error_magnitudes[ERROR_NUM] = {0};
	int i = 0;
	int error_location = 0;

	compute_syndrome(syndrome, received_codeword);
	get_error_locate_poly(locators, ERROR_NUM, error_locator_poly);
	get_evaluator_poly(syndrome, error_locator_poly, error_evaluator_poly);
	get_formal_derivation(error_locator_poly, error_locator_poly_derivative, (N - K)/2 + 1);
	evaluate_error(error_magnitudes, error_locator_poly_derivative, error_evaluator_poly, locators,ERROR_NUM);
	//add the error magnitudes to received codeword
	for(i = 0; i < ERROR_NUM; i++){
		error_location = galois_log(locators[i], w);
		received_codeword[error_location] ^= error_magnitudes[i];		
	}
}
Example #4
0
/*
* Class:     eu_vandertil_jerasure_jni_Galois
* Method:    galois_log
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_eu_vandertil_jerasure_jni_Galois_galois_1log
	(JNIEnv *env, jclass clazz, jint value, jint w)
{
	return galois_log(value, w);
}