min_poly.cpp
上传用户:jtjnyq9001
上传日期:2014-11-21
资源大小:3974k
文件大小:1k
源码类别:

3G开发

开发平台:

Visual C++

  1. //
  2. // primpoly.cpp
  3. //
  4. #include <iostream>
  5. #include <fstream>
  6. #include "min_poly.h"
  7. #include "ipow.h"
  8. #include "poly_xf.h"
  9. //using namespace std;
  10. extern ::ofstream DebugFile;
  11. //=====================================================
  12. MinimalPolynomial::MinimalPolynomial( GaloisField* exten_field, 
  13.                                       CyclotomicCoset *coset )
  14. {
  15.    int num_factors;
  16.    int i,expon;
  17.    PolyOvrExtenField** factors;
  18.    ExtenFieldElem* element;
  19.    num_factors = coset->size;
  20.    factors = new PolyOvrExtenField*[num_factors];
  21.   
  22.    for(i=0; i<num_factors; i++){
  23.       expon = coset->start[i];
  24.       //element = new ExtenFieldElem(exten_field,expon);
  25.       element = &(exten_field->GetElement(expon));
  26.       factors[i] = new PolyOvrExtenField(exten_field, *element);
  27.    }
  28.    for(i=1; i<num_factors; i++){
  29.       factors[0]->operator *=(*(factors[i]));
  30.    }
  31.    Coeff = new PrimeFieldElem[num_factors+1];
  32.    for(i=0; i<=num_factors; i++){
  33.       Coeff[i].Value = factors[0]->Coeff_Xf[i].Value[0].Value;
  34.       Coeff[i].Modulus = factors[0]->Coeff_Xf[i].Value[0].Modulus;
  35.    }
  36.    Prime_Base = 2;
  37.    Degree = num_factors;
  38.    for(i=0; i<num_factors; i++){
  39.       delete factors[i];
  40.    }
  41.    delete[] factors;
  42. }