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

3G开发

开发平台:

Visual C++

  1. // poly_pf.cpp
  2. //
  3. #include <iostream>
  4. #include <fstream>
  5. #include "poly_pf.h"
  6. #include "pfelem.h"
  7. #include "stdlib.h"
  8. extern ofstream DebugFile;
  9. //============================================================
  10. PolyOvrPrimeField::PolyOvrPrimeField( int prime_base,
  11.                                       int degree,
  12.                                       rowvec_pf *coeff)
  13. {
  14.   int i;
  15.   Prime_Base = prime_base;
  16.   Degree = degree;
  17.   Coeff = new PrimeFieldElem[Degree+1];
  18.   for(i=0; i<=Degree; i++)
  19.     {
  20.     Coeff[i] = ((*coeff)[i]);
  21.     }
  22. }
  23. //============================================================
  24. PolyOvrPrimeField::PolyOvrPrimeField( int prime_base,
  25.                                       rowvec_pf *coeff)
  26. {
  27.   int i;
  28.   int len = coeff->getlen();
  29.   Prime_Base = prime_base;
  30.   Degree = 0;
  31.   for(i=0; i<len; i++)
  32.     {
  33.     if( (*coeff)[i].Value != 0 ) Degree=i;
  34.     }
  35.   Coeff = new PrimeFieldElem[Degree+1];
  36.   for(i=0; i<=Degree; i++)
  37.     {
  38.     Coeff[i] = (*coeff)[i];
  39.     }
  40. }