Пример #1
0
int _tmain(int argc, _TCHAR* argv[])
{
	Vector2 sites[] = {
		//WARNING: 最初の3つの母点は現在反時計回り前提
		Vector2(100, 500),
		Vector2(400, 500),
		Vector2(250, 500 + 150 * std::sqrtf(3)),
		//BUG: 4つ目元の三角形の内側以外はNG!
		//=>無限遠辺に対するHがおかしい。原点とのBISECTOR取らないように
		//  Vector3HのregionAroundVertexを変更し、Vector2 oneEuclidRegionAroundVertex とする。
		//Vector2(200, 550)
		//Vector2(350, 540)
		Vector2(220, 450)
	};

	RootGraph G0(sites[0], sites[1], sites[2]);
	std::size_t l = 3;		//処理済の母店数
	auto G1 = updatedVoronoiDiagram(G0, sites, l++);
	//BUG: 実行するとG1が壊れる! moveコンストラクタの扱いのミス?
	//auto G2 = updatedVoronoiDiagram(G1, sites, l++);

	//出力
	WriteVoronoiToPsFile("voronoi0.ps", G0);
	WriteVoronoiToPsFile("voronoi1.ps", G1);
	//WriteVoronoiToPsFile("voronoi2.ps", G2);

	return 0;
}
Пример #2
0
bool SingleVarStats::GetModelGraphic(CMdlGraphicArray & Grfs)
{
	CMdlGraphic G0(0, MGT_Simple, true, "Histogram", 1);

	Grfs.SetSize(0);
	Grfs.SetAtGrow(0, G0);
	return true;
}
Пример #3
0
bool CTrompCurve::GetModelGraphic(CMdlGraphicArray & Grfs)
  {
  CMdlGraphic G0(0, MGT_Simple, true, "Split Graphic", 1);

  Grfs.SetSize(0);
  Grfs.SetAtGrow(0, G0);
  return true;
  };
Пример #4
0
static
V
calc_edge_score(const boost::multi_array<V,2>& si_subst,
		const std::vector<V>& gap,
		const Data& xx, const Data& yy,
		uint x_i, uint x_j, uint y_i, uint y_j)
{
  typedef V value_type;
  typedef typename Data::Seq Seq;
  typedef boost::multi_array<value_type,2> dp_type;
  const Seq& x(xx.seq);
  const Seq& y(yy.seq);
  const std::vector<float>& w_x(xx.weight);
  const std::vector<float>& w_y(yy.weight);
  uint sz_x = x_i<=x_j ? x_j-x_i+1 : 0;
  uint sz_y = y_i<=y_j ? y_j-y_i+1 : 0;

  if (sz_x==0) { return gap[sz_y]; }
  if (sz_y==0) { return gap[sz_x]; }

  dp_type K0(boost::extents[sz_x+1][sz_y+1]);
  dp_type G0(boost::extents[sz_x+1][sz_y+1]);
  std::vector<value_type> K1(sz_y+1);
  std::vector<value_type> G1(sz_y+1);

  K0[0][0] = G0[0][0] = 1.0;
  for (uint i=1; i!=sz_x+1; ++i) {
    K0[i][0] = 1.0;
    G0[i][0] = G0[i-1][0]*gap[1];
  }
  for (uint j=1; j!=sz_y+1; ++j) {
    K0[0][j] = 1.0;
    G0[0][j] = G0[0][j-1]*gap[1];
  }

  for (uint i=1; i!=sz_x+1; ++i) {
    K1[0] = G1[0] = 0.0;
    uint ii=x_i+i;
    for (uint j=1; j!=sz_y+1; ++j) {
      uint jj=y_i+j;
      value_type v = G0[i-1][j-1];
      v *= subst_score(si_subst,x[ii-1],y[jj-1]);
      v *= w_x[ii-1]*w_y[jj-1];
      K1[j] = v + K1[j-1];
      G1[j] = v + G1[j-1]*gap[1];
      K0[i][j] = K1[j] + K0[i-1][j];
      G0[i][j] = G1[j] + G0[i-1][j]*gap[1];
    }
  }

  return K0[sz_x][sz_y];
}
Пример #5
0
Файл: luit.c Проект: aosm/X11
static int
parseOptions(int argc, char **argv)
{
    int i = 1;
    while(i < argc) {
        if(argv[i][0] != '-' && argv[i][0] != '+') {
            break;
        } else if(!strcmp(argv[i], "--")) {
            i++;
            break;
        } else if(!strcmp(argv[i], "-v")) {
            verbose++;
            i++;
        } else if(!strcmp(argv[i], "-h")) {
            help();
            exit(0);
        } else if(!strcmp(argv[i], "-list")) {
            reportCharsets();
            exit(0);
        } else if(!strcmp(argv[i], "+oss")) {
            outputState->outputFlags &= ~OF_SS;
            i++;
        } else if(!strcmp(argv[i], "+ols")) {
            outputState->outputFlags &= ~OF_LS;
            i++;
        } else if(!strcmp(argv[i], "+osl")) {
            outputState->outputFlags &= ~OF_SELECT;
            i++;
        } else if(!strcmp(argv[i], "+ot")) {
            outputState->outputFlags = OF_PASSTHRU;
            i++;
        } else if(!strcmp(argv[i], "-k7")) {
            inputState->inputFlags &= ~IF_EIGHTBIT;
            i++;
        } else if(!strcmp(argv[i], "+kss")) {
            inputState->inputFlags &= ~IF_SS;
            i++;
        } else if(!strcmp(argv[1], "+kssgr")) {
            inputState->inputFlags &= ~IF_SSGR;
            i++;
        } else if(!strcmp(argv[i], "-kls")) {
            inputState->inputFlags |= IF_LS;
            i++;
        } else if(!strcmp(argv[i], "-g0")) {
            if(i + 1 >= argc)
                FatalError("-g0 requires an argument\n");
            G0(outputState) = getCharsetByName(argv[i + 1]);
            i += 2;
        } else if(!strcmp(argv[i], "-g1")) {
            if(i + 1 >= argc)
                FatalError("-g1 requires an argument\n");
            G1(outputState) = getCharsetByName(argv[i + 1]);
            i += 2;
        } else if(!strcmp(argv[i], "-g2")) {
            if(i + 1 >= argc)
                FatalError("-g2 requires an argument\n");
            G2(outputState) = getCharsetByName(argv[i + 1]);
            i += 2;
        } else if(!strcmp(argv[i], "-g3")) {
            if(i + 1 >= argc)
                FatalError("-g3 requires an argument\n");
            G3(outputState) = getCharsetByName(argv[i + 1]);

            i += 2;
        } else if(!strcmp(argv[i], "-gl")) {
            int j;
            if(i + 1 >= argc)
                FatalError("-gl requires an argument\n");
            if(strlen(argv[i + 1]) != 2 ||
               argv[i + 1][0] != 'g')
                j = -1;
            else 
                j = argv[i + 1][1] - '0';
            if(j < 0 || j > 3)
                FatalError("The argument of -gl "
                           "should be one of g0 through g3,\n"
                           "not %s\n", argv[i + 1]);
            else
                outputState->glp = &outputState->g[j];
            i += 2;
        } else if(!strcmp(argv[i], "-gr")) {
            int j;
            if(i + 1 >= argc)
                FatalError("-gr requires an argument\n");
            if(strlen(argv[i + 1]) != 2 ||
               argv[i + 1][0] != 'g')
                j = -1;
            else 
                j = argv[i + 1][1] - '0';
            if(j < 0 || j > 3)
                FatalError("The argument of -gl "
                           "should be one of g0 through g3,\n"
                           "not %s\n", argv[i + 1]);
            else
                outputState->grp = &outputState->g[j];
            i += 2;
        } else if(!strcmp(argv[i], "-kg0")) {
            if(i + 1 >= argc)
                FatalError("-kg0 requires an argument\n");
            G0(inputState) = getCharsetByName(argv[i + 1]);
            i += 2;
        } else if(!strcmp(argv[i], "-kg1")) {
            if(i + 1 >= argc)
                FatalError("-kg1 requires an argument\n");
            G1(inputState) = getCharsetByName(argv[i + 1]);
            i += 2;
        } else if(!strcmp(argv[i], "-kg2")) {
            if(i + 1 >= argc)
                FatalError("-kg2 requires an argument\n");
            G2(inputState) = getCharsetByName(argv[i + 1]);
            i += 2;
        } else if(!strcmp(argv[i], "-kg3")) {
            if(i + 1 >= argc)
                FatalError("-kg3 requires an argument\n");
            G3(inputState) = getCharsetByName(argv[i + 1]);

            i += 2;
        } else if(!strcmp(argv[i], "-kgl")) {
            int j;
            if(i + 1 >= argc)
                FatalError("-kgl requires an argument\n");
            if(strlen(argv[i + 1]) != 2 ||
               argv[i + 1][0] != 'g')
                j = -1;
            else 
                j = argv[i + 1][1] - '0';
            if(j < 0 || j > 3)
                FatalError("The argument of -kgl "
                           "should be one of g0 through g3,\n"
                           "not %s\n", argv[i + 1]);
            else
                inputState->glp = &inputState->g[j];
            i += 2;
        } else if(!strcmp(argv[i], "-kgr")) {
            int j;
            if(i + 1 >= argc)
                FatalError("-kgl requires an argument\n");
            if(strlen(argv[i + 1]) != 2 ||
               argv[i + 1][0] != 'g')
                j = -1;
            else 
                j = argv[i + 1][1] - '0';
            if(j < 0 || j > 3)
                FatalError("The argument of -kgl "
                           "should be one of g0 through g3,\n"
                           "not %s\n", argv[i + 1]);
            else
                inputState->grp = &inputState->g[j];
            i += 2;
        } else if(!strcmp(argv[i], "-argv0")) {
            if(i + 1 >= argc)
                FatalError("-argv0 requires an argument\n");
            child_argv0 = argv[i + 1];
            i += 2;
        } else if(!strcmp(argv[i], "-x")) {
            exitOnChild = 1;
            i++;
        } else if(!strcmp(argv[i], "-c")) {
            converter = 1;
            i++;
        } else if(!strcmp(argv[i], "-ilog")) {
            if(i + 1 >= argc)
                FatalError("-ilog requires an argument\n");
            ilog = open(argv[i + 1], O_WRONLY | O_CREAT | O_TRUNC, 0777);
            if(ilog < 0) {
                perror("Couldn't open input log");
                exit(1);
            }
            i += 2;
        } else if(!strcmp(argv[i], "-olog")) {
            if(i + 1 >= argc)
                FatalError("-olog requires an argument\n");
            olog = open(argv[i + 1], O_WRONLY | O_CREAT | O_TRUNC, 0777);
            if(olog < 0) {
                perror("Couldn't open output log");
                exit(1);
            }
            i += 2;
        } else if(!strcmp(argv[i], "-encoding")) {
            int rc;
            if(i + 1 >= argc)
                FatalError("-encoding requires an argument\n");
            rc = initIso2022(NULL, argv[i + 1], outputState);
            if(rc < 0)
                FatalError("Couldn't init output state\n");
            i += 2;
        } else {
            FatalError("Unknown option %s\n", argv[i]);
        }
    }
    return i;
}
Пример #6
0
  void SurfaceVectorGradient<EvalT, Traits>::
  evaluateFields(typename Traits::EvalData workset)
  {
    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
      for (std::size_t pt=0; pt < numQPs; ++pt) {
        Intrepid::Vector<ScalarT> g_0(3, &currentBasis(cell, pt, 0, 0));
        Intrepid::Vector<ScalarT> g_1(3, &currentBasis(cell, pt, 1, 0));
        Intrepid::Vector<ScalarT> g_2(3, &currentBasis(cell, pt, 2, 0));
        Intrepid::Vector<ScalarT> G_2(3, &refNormal(cell, pt, 0));
        Intrepid::Vector<ScalarT> d(3, &jump(cell, pt, 0));
        Intrepid::Vector<ScalarT> G0(3, &refDualBasis(cell, pt, 0, 0));
        Intrepid::Vector<ScalarT> G1(3, &refDualBasis(cell, pt, 1, 0));
        Intrepid::Vector<ScalarT> G2(3, &refDualBasis(cell, pt, 2, 0));

        Intrepid::Tensor<ScalarT>
        Fpar(Intrepid::bun(g_0, G0) +
            Intrepid::bun(g_1, G1) +
            Intrepid::bun(g_2, G2));
        // for Jay: bun()
        Intrepid::Tensor<ScalarT> Fper((1 / thickness) * Intrepid::bun(d, G_2));

        Intrepid::Tensor<ScalarT> F = Fpar + Fper;

        defGrad(cell, pt, 0, 0) = F(0, 0);
        defGrad(cell, pt, 0, 1) = F(0, 1);
        defGrad(cell, pt, 0, 2) = F(0, 2);
        defGrad(cell, pt, 1, 0) = F(1, 0);
        defGrad(cell, pt, 1, 1) = F(1, 1);
        defGrad(cell, pt, 1, 2) = F(1, 2);
        defGrad(cell, pt, 2, 0) = F(2, 0);
        defGrad(cell, pt, 2, 1) = F(2, 1);
        defGrad(cell, pt, 2, 2) = F(2, 2);

        J(cell,pt) = Intrepid::det(F);
      }
    }

    if (weightedAverage)
    {
      ScalarT Jbar, wJbar, vol;
      for (std::size_t cell=0; cell < workset.numCells; ++cell)
      {
        Jbar = 0.0;
        vol = 0.0;
        for (std::size_t qp=0; qp < numQPs; ++qp)
        {
          Jbar += weights(cell,qp) * std::log( J(cell,qp) );
          vol  += weights(cell,qp);
        }
        Jbar /= vol;

        // Jbar = std::exp(Jbar);
        for (std::size_t qp=0; qp < numQPs; ++qp)
        {
          for (std::size_t i=0; i < numDims; ++i)
          {
            for (std::size_t j=0; j < numDims; ++j)
            {
              wJbar = std::exp( (1-alpha) * Jbar + alpha * std::log( J(cell,qp) ) );
              defGrad(cell,qp,i,j) *= std::pow( wJbar / J(cell,qp) ,1./3. );
            }
          }
          J(cell,qp) = wJbar;
        }
      }
    }

  }
Пример #7
0
// Assumes symbol-spaced sampling!!!
// Based upon paper by Al-Dhahir and Cioffi
bool designDFE(signalVector &channelResponse,
	       float SNRestimate,
	       int Nf,
	       signalVector **feedForwardFilter,
	       signalVector **feedbackFilter)
{
  
  signalVector G0(Nf);
  signalVector G1(Nf);
  signalVector::iterator G0ptr = G0.begin();
  signalVector::iterator G1ptr = G1.begin();
  signalVector::iterator chanPtr = channelResponse.begin();

  int nu = channelResponse.size()-1;

  *G0ptr = 1.0/sqrtf(SNRestimate);
  for(int j = 0; j <= nu; j++) {
    *G1ptr = chanPtr->conj();
    G1ptr++; chanPtr++;
  }

  signalVector *L[Nf];
  signalVector::iterator Lptr;
  float d;
  for(int i = 0; i < Nf; i++) {
    d = G0.begin()->norm2() + G1.begin()->norm2();
    L[i] = new signalVector(Nf+nu);
    Lptr = L[i]->begin()+i;
    G0ptr = G0.begin(); G1ptr = G1.begin();
    while ((G0ptr < G0.end()) &&  (Lptr < L[i]->end())) {
      *Lptr = (*G0ptr*(G0.begin()->conj()) + *G1ptr*(G1.begin()->conj()) )/d;
      Lptr++;
      G0ptr++;
      G1ptr++;
    }
    complex k = (*G1.begin())/(*G0.begin());

    if (i != Nf-1) {
      signalVector G0new = G1;
      scaleVector(G0new,k.conj());
      addVector(G0new,G0);

      signalVector G1new = G0;
      scaleVector(G1new,k*(-1.0));
      addVector(G1new,G1);
      delayVector(G1new,-1.0);

      scaleVector(G0new,1.0/sqrtf(1.0+k.norm2()));
      scaleVector(G1new,1.0/sqrtf(1.0+k.norm2()));
      G0 = G0new;
      G1 = G1new;
    }
  }

  *feedbackFilter = new signalVector(nu);
  L[Nf-1]->segmentCopyTo(**feedbackFilter,Nf,nu);
  scaleVector(**feedbackFilter,(complex) -1.0);
  conjugateVector(**feedbackFilter);

  signalVector v(Nf);
  signalVector::iterator vStart = v.begin();
  signalVector::iterator vPtr;
  *(vStart+Nf-1) = (complex) 1.0;
  for(int k = Nf-2; k >= 0; k--) {
    Lptr = L[k]->begin()+k+1;
    vPtr = vStart + k+1;
    complex v_k = 0.0;
    for (int j = k+1; j < Nf; j++) {
      v_k -= (*vPtr)*(*Lptr);
      vPtr++; Lptr++;
    }
     *(vStart + k) = v_k;
  }

  *feedForwardFilter = new signalVector(Nf);
  signalVector::iterator w = (*feedForwardFilter)->begin();
  for (int i = 0; i < Nf; i++) {
    delete L[i];
    complex w_i = 0.0;
    int endPt = ( nu < (Nf-1-i) ) ? nu : (Nf-1-i);
    vPtr = vStart+i;
    chanPtr = channelResponse.begin();
    for (int k = 0; k < endPt+1; k++) {
      w_i += (*vPtr)*(chanPtr->conj());
      vPtr++; chanPtr++;
    }
    *w = w_i/d;
    w++;
  }


  return true;
  
}
Пример #8
0
ValueType
StringKernel<ValueType>::
operator()(const std::string& x, const std::string& y) const
{
  const value_type& g=gap_;
  value_type g2=g*g;
  typedef boost::multi_array<value_type,2> dp_type;
#if 1

  dp_type K0(boost::extents[x.size()+1][y.size()+1]);
  dp_type G0(boost::extents[x.size()+1][y.size()+1]);
  std::vector<value_type> K1(y.size()+1);
  std::vector<value_type> G1(y.size()+1);

  K0[0][0]=G0[0][0]=1.0;
  for (uint i=1; i!=x.size()+1; ++i) {
    K0[i][0]=1.0;
    G0[i][0]=G0[i-1][0]*g;
  }
  for (uint j=1; j!=y.size()+1; ++j) {
    K0[0][j]=1.0;
    G0[0][j]=G0[0][j-1]*g;
  }

  for (uint i=1; i!=x.size()+1; ++i) {
    K1[0]=G1[0]=0.0;
    for (uint j=1; j!=y.size()+1; ++j) {
      K1[j] = K1[j-1];
      G1[j] = G1[j-1]*g;
      if (x[i-1]==y[j-1]) {
	K1[j] += G0[i-1][j-1]*g2;
	G1[j] += G0[i-1][j-1]*g2;
      }
      K0[i][j] = K0[i-1][j] + K1[j];
      G0[i][j] = G0[i-1][j]*g + G1[j];
    }
  }

  return K0[x.size()][y.size()];

#else

  dp_type K0(boost::extents[x.size()+1][y.size()+1]);
  dp_type G0(boost::extents[x.size()+1][y.size()+1]);
  dp_type K1(boost::extents[x.size()+1][y.size()+1]);
  dp_type G1(boost::extents[x.size()+1][y.size()+1]);

  K0[0][0]=G0[0][0]=1.0;
  for (uint i=1; i!=x.size()+1; ++i) {
    K0[i][0]=1.0;
    G0[i][0]=G0[i-1][0]*g;
  }
  for (uint j=1; j!=y.size()+1; ++j) {
    K0[0][j]=1.0;
    G0[0][j]=G0[0][j-1]*g;
  }

  for (uint i=1; i!=x.size()+1; ++i) {
    K1[i][0]=G1[i][0]=0.0;
    for (uint j=1; j!=y.size()+1; ++j) {
      K1[i][j] = K1[i][j-1];
      G1[i][j] = G1[i][j-1]*g;
      if (x[i-1]==y[j-1]) {
	K1[i][j] += G0[i-1][j-1]*g2;
	G1[i][j] += G0[i-1][j-1]*g2;
      }
      K0[i][j] = K0[i-1][j] + K1[i][j];
      G0[i][j] = G0[i-1][j]*g + G1[i][j];
    }
  }

  return K0[x.size()][y.size()];
#endif
}
Пример #9
0
int EmbedPolyline(TopologicalGraph &G)
  {if(G.nv() < 3 || G.ne() < 2)return -1;
  int OldNumEdge = G.ne();
  PSet1  propSave(G.Set());
  G.MakeConnected();
  if(!G.FindPlanarMap() )
      {Tprintf("Not Planar Graph");
      for(tedge e = G.ne(); e > OldNumEdge; e--) G.DeleteEdge(e);
      return -1;
      }
 tbrin FirstBrin = 1;
  bool MaxPlanar = (G.ne() != 3 * G.nv() - 6) ? false : true;
  int len;
  if(!FirstBrin && !MaxPlanar)
      G.LongestFace(FirstBrin,len);
  else if(FirstBrin == 0)
      {FirstBrin = G.extbrin();FirstBrin = -G.acir[FirstBrin];}

  if(!MaxPlanar && G.ZigZagTriangulate())return -2;
  svector<short> ecolor(1, G.ne());
  SchnyderDecomp(G,FirstBrin,ecolor);
  GeometricGraph G0(G);
  
  //Compute trees 
  tedge ee;
  Prop<Tpoint> Ebend(G.Set(tedge()),PROP_DRAW_POINT_3);
  
  svector<tbrin> FatherB(1,G.nv(),(tbrin)0);           FatherB.SetName("FatherB");
  svector<tbrin> FatherG(1,G.nv(),(tbrin)0);           FatherG.SetName("FatherG");
  svector<tbrin> FatherR(1,G.nv(),(tbrin)0);           FatherR.SetName("FatherR");
  svector<int> x(1,G.nv(),0), y(1,G.nv(),0);
  x.clear(); y.clear();
  compute_parents(G0, Blue, -FirstBrin, FatherB, ecolor);
  compute_parents(G0, Red, FirstBrin, FatherR, ecolor);
  compute_parents(G0, Green, -G0.acir[FirstBrin], FatherG, ecolor);
  // Compute the number of leaves of each tree
  int nb_leavesB, nb_leavesR, nb_leavesG;
  nb_leavesB = nb_leaves(G0, Blue, -FirstBrin, ecolor);
  nb_leavesR = nb_leaves(G0, Red, FirstBrin, ecolor);
  nb_leavesG = nb_leaves(G0, Green, -G0.acir[FirstBrin], ecolor);

    // Compute the coordinates using the tree with the minimum number of leaves
  ForAllEdges(ee, G) Ebend[ee] = Tpoint(-1,-1);
  if (nb_leavesB <= nb_leavesR && nb_leavesB <= nb_leavesG) 
      compute_coords(G0,Red,Blue,-FirstBrin,FatherB,FatherR,FatherG,ecolor,x,y,Ebend);
  else if (nb_leavesR <= nb_leavesG) 
      compute_coords(G0,Green,Red,G0.acir[FirstBrin],FatherR,FatherG,FatherB,ecolor,x,y,Ebend);
  else 
      compute_coords(G0,Blue,Green,G0.acir[-G0.acir[FirstBrin]],FatherG,FatherB,FatherR,ecolor,x,y,Ebend);
  // computes extremities of vertices
  Prop<Tpoint> Epoint1(G.Set(tedge()),PROP_DRAW_POINT_1);
  Prop<Tpoint> Epoint2(G.Set(tedge()),PROP_DRAW_POINT_2);
  Prop<Tpoint> Vcoord(G.Set(tvertex()),PROP_DRAW_POINT_1);
  G.Set() =  propSave;
  Prop1<Tpoint> pmin(G.Set(),PROP_POINT_MIN);
  Prop1<Tpoint> pmax(G.Set(),PROP_POINT_MAX);  
  tvertex vv;
  pmin() = Tpoint(0,0);
  pmax() = Tpoint(0,0);
  ForAllVertices(vv, G0) 
   {Vcoord[vv] = Tpoint(x[vv], y[vv]);
   if (Vcoord[vv].x() > pmax().x())
       pmax().x() = Vcoord[vv].x();
   if (Vcoord[vv].y() > pmax().y())
       pmax().y() = Vcoord[vv].y();
   }
Пример #10
0
void raazHashBlake256PortableCompress(Hash hash, Salt salt, uint64_t counter, int nblocks, Block *mesg)
{

    Word t0,t1;  /* Counter variables */

    /* Message variables */
    Word m0;    
    Word m1;
    Word m2;
    Word m3;
    Word m4;    
    Word m5;
    Word m6;
    Word m7;
    Word m8;
    Word m9;
    Word m10;
    Word m11;
    Word m12;
    Word m13;
    Word m14;
    Word m15;
    
    /* State variables - stored in registers so as to make the code faster */
    register Word v0;
    register Word v1;
    register Word v2;
    register Word v3;
    register Word v4;
    register Word v5;
    register Word v6;
    register Word v7;
    register Word v8;
    register Word v9;
    register Word v10;
    register Word v11;
    register Word v12;
    register Word v13;
    register Word v14;
    register Word v15;


    while(nblocks > 0)
    {
        /* Incrementing counter by message bits */
        counter = counter + 512;  
    
        t0 = (Word)counter;                    
        t1 = (Word)(counter >> 32);
                
        /* Initialization of the state consisting of 16 words */                
        v0 = hash[0];
        v1 = hash[1];
        v2 = hash[2];
        v3 = hash[3];
        v4 = hash[4];
        v5 = hash[5];
        v6 = hash[6];
        v7 = hash[7];
        v8 = salt[0] ^ c0;
        v9 = salt[1] ^ c1;
        v10 = salt[2] ^ c2; 
        v11 = salt[3] ^ c3;
        v12 = t0 ^ c4; 
        v13 = t0 ^ c5; 
        v14 = t1 ^ c6; 
        v15 = t1 ^ c7;

        /* Loading the message into 16 words */     
        m0 = raazLoad32BE((Word *)mesg,0);
        m1 = raazLoad32BE((Word *)mesg,1);
        m2 = raazLoad32BE((Word *)mesg,2);
        m3 = raazLoad32BE((Word *)mesg,3);
        m4 = raazLoad32BE((Word *)mesg,4);
        m5 = raazLoad32BE((Word *)mesg,5);
        m6 = raazLoad32BE((Word *)mesg,6);
        m7 = raazLoad32BE((Word *)mesg,7);
        m8 = raazLoad32BE((Word *)mesg,8);
        m9 = raazLoad32BE((Word *)mesg,9);
        m10 = raazLoad32BE((Word *)mesg,10); 
        m11 = raazLoad32BE((Word *)mesg,11); 
        m12 = raazLoad32BE((Word *)mesg,12); 
        m13 = raazLoad32BE((Word *)mesg,13); 
        m14 = raazLoad32BE((Word *)mesg,14); 
        m15 = raazLoad32BE((Word *)mesg,15);
        
        /* End of reading the message block */


        /*
        Loop unrollings are being done after every round so as to improve the 
        performance. 
        */

        /* Round 1 */
        /* Column Steps 0-3 */
        G0( m0, m1, c0, c1 );
        G1( m2, m3, c2, c3 );
        G2( m4, m5, c4, c5 );
        G3( m6, m7, c6, c7 );

        /* Diagonal-Step 4-7 */  
        G4( m8 , m9 , c8 , c9  );
        G5( m10, m11, c10, c11 );
        G6( m12, m13, c12, c13 );
        G7( m14, m15, c14, c15 );


        /* Round 2 */
        /* Column Step 0-3 */
        G0( m14, m10, c14, c10 );
        G1( m4 , m8 , c4 , c8  );
        G2( m9 , m15, c9 , c15 );
        G3( m13, m6 , c13, c6  );

        /* Diagonal Step 4-7 */
        G4( m1 , m12, c1 , c12 );
        G5( m0 , m2 , c0 , c2  );
        G6( m11, m7 , c11, c7  );
        G7( m5 , m3 , c5 , c3  );


        /* Round 3 */
        /* Column Step 0-3 */
        G0( m11, m8 , c11, c8  );
        G1( m12, m0 , c12, c0  );
        G2( m5 , m2 , c5 , c2  );
        G3( m15, m13, c15, c13 );

        /* Diagonal Step 4-7 */
        G4( m10, m14, c10, c14 );
        G5( m3 , m6 , c3 , c6  );
        G6( m7 , m1 , c7 , c1  );
        G7( m9 , m4 , c9 , c4  );


        /* Round 4 */
        /* Column Step 0-3 */
        G0( m7 , m9 , c7 , c9  );
        G1( m3 , m1 , c3 , c1  );
        G2( m13, m12, c13, c12 );
        G3( m11, m14, c11, c14 );

        /* Diagonal Step 4-7 */
        G4( m2 , m6 , c2 , c6  );
        G5( m5 , m10, c5 , c10 );
        G6( m4 , m0 , c4 , c0  );
        G7( m15, m8 , c15, c8  );


        /* Round 5 */
        /* Column Step 0-3 */
        G0( m9 , m0 , c9 , c0  );
        G1( m5 , m7 , c5 , c7  );
        G2( m2 , m4 , c2 , c4  );
        G3( m10, m15, c10, c15 );

        /* Diagonal Step 4-7 */
        G4( m14, m1 , c14, c1  );
        G5( m11, m12, c11, c12 );
        G6( m6 , m8 , c6 , c8  );
        G7( m3 , m13, c3 , c13 );


        /* Round 6 */
        /* Column Step 0-3 */
        G0( m2, m12, c2, c12 );
        G1( m6, m10, c6, c10 );
        G2( m0, m11, c0, c11 );
        G3( m8, m3 , c8, c3  );

        /* Diagonal Step 4-7 */
        G4( m4 , m13, c4 , c13 );
        G5( m7 , m5 , c7 , c5  );
        G6( m15, m14, c15, c14 );
        G7( m1 , m9 , c1 , c9  );


        /* Round 7 */
        /* Column Step 0-3 */
        G0( m12, m5 , c12, c5 );
        G1( m1 , m15, c1 , c15 );
        G2( m14, m13, c14, c13 );
        G3( m4 , m10, c4 , c10 );

        /* Diagonal Step 4-7 */
        G4( m0, m7 , c0, c7  );
        G5( m6, m3 , c6, c3  );
        G6( m9, m2 , c9, c2  ); 
        G7( m8, m11, c8, c11 );


        /* Round 8 */
        /* Column Step 0-3 */
        G0( m13, m11, c13, c11 );
        G1( m7 , m14, c7 , c14 );
        G2( m12, m1 , c12, c1  );
        G3( m3 , m9 , c3 , c9  );

        /* Diagonal Step 4-7 */
        G4( m5 , m0 , c5 , c0  );
        G5( m15, m4 , c15, c4  );
        G6( m8 , m6 , c8 , c6  );
        G7( m2 , m10, c2 , c10 );


        /* Round 9 */
        /* Column Step 0-3 */
        G0( m6 , m15, c6 , c15 );
        G1( m14, m9 , c14, c9  );
        G2( m11, m3 , c11, c3  );
        G3( m0 , m8 , c0 , c8  );

        /* Diagonal Step 4-7 */
        G4( m12, m2, c12, c2 );
        G5( m13, m7, c13, c7 );
        G6( m1 , m4, c1 , c4 );
        G7( m10, m5, c10, c5 );


        /* Round 10 */
        /* Column Step 0-3 */
        G0( m10, m2, c10, c2 );
        G1( m8 , m4, c8 , c4 );
        G2( m7 , m6, c7 , c6 );
        G3( m1 , m5, c1 , c5 );

        /* Diagonal Step 4-7 */
        G4( m15, m11, c15, c11 );
        G5( m9 , m14, c9 , c14 );
        G6( m3 , m12, c3 , c12 );
        G7( m13, m0 , c13, c0  );


        /* Round 11 */
        /* Column Steps 0-3 */
        G0( m0, m1, c0, c1 );
        G1( m2, m3, c2, c3 );
        G2( m4, m5, c4, c5 );
        G3( m6, m7, c6, c7 );

        /* Diagonal-Step 4-7 */  
        G4( m8 , m9 , c8 , c9  );
        G5( m10, m11, c10, c11 );
        G6( m12, m13, c12, c13 );
        G7( m14, m15, c14, c15 );
        

        /* Round 12 */
        /* Column Step 0-3 */
        G0( m14, m10, c14, c10 );
        G1( m4 , m8 , c4 , c8  );
        G2( m9 , m15, c9 , c15 );
        G3( m13, m6 , c13, c6  );

        /* Diagonal Step 4-7 */
        G4( m1 , m12, c1 , c12 );
        G5( m0 , m2 , c0 , c2  );
        G6( m11, m7 , c11, c7  );
        G7( m5 , m3 , c5 , c3  );


        /* Round 13 */
        /* Column Step 0-3 */
        G0( m11, m8 , c11, c8  );
        G1( m12, m0 , c12, c0  );
        G2( m5 , m2 , c5 , c2  );
        G3( m15, m13, c15, c13 );
  
        /* Diagonal Step 4-7 */
        G4( m10, m14, c10, c14 );
        G5( m3 , m6 , c3 , c6  );
        G6( m7 , m1 , c7 , c1  );
        G7( m9 , m4 , c9 , c4  );


        /* Round 14 */
        /* Column Step 0-3 */
        G0( m7 , m9 , c7 , c9  );
        G1( m3 , m1 , c3 , c1  );
        G2( m13, m12, c13, c12 );
        G3( m11, m14, c11, c14 );

        /* Diagonal Step 4-7 */
        G4( m2 , m6 , c2 , c6  );
        G5( m5 , m10, c5 , c10 );
        G6( m4 , m0 , c4 , c0  );
        G7( m15, m8 , c15, c8  );



        /* Updation of hash variables with the new chain value */
        hash[0] = hash[0] ^ salt[0] ^ v0 ^ v8;
        hash[1] = hash[1] ^ salt[1] ^ v1 ^ v9;
        hash[2] = hash[2] ^ salt[2] ^ v2 ^ v10;
        hash[3] = hash[3] ^ salt[3] ^ v3 ^ v11;
        hash[4] = hash[4] ^ salt[0] ^ v4 ^ v12;     
        hash[5] = hash[5] ^ salt[1] ^ v5 ^ v13;     
        hash[6] = hash[6] ^ salt[2] ^ v6 ^ v14; 
        hash[7] = hash[7] ^ salt[3] ^ v7 ^ v15;     
        
        ++mesg; /* Incrementing to the next block */
        --nblocks;
    }   
}
Пример #11
0
std::complex<double> H0(T p2, T m2a, T m2b, double scl2)
{
    return 4.0*B00(p2, m2a, m2b, scl2) + G0(p2, m2a, m2b, scl2);
}