当前位置: 首页>>代码示例>>C++>>正文


C++ HH函数代码示例

本文整理汇总了C++中HH函数的典型用法代码示例。如果您正苦于以下问题:C++ HH函数的具体用法?C++ HH怎么用?C++ HH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: L

static struct avl_node *_avlInsert(struct avl_node *n, int key)
{
    if(!n) return _avlNewNode(key);


    if(key < K(n)) {
        L(n) = _avlInsert(L(n), key);
    }
    else {
        R(n) = _avlInsert(R(n), key);
    }
    H(n) = MAX(HH(n->left), HH(n->right)) + 1;

    int bf = BF(n);

    if(bf > 1) {
        if(key > K(L(n))) { // LR case
            L(n) = _leftRotate(L(n));
        }
        // else LL case
        return _rightRotate(n);
    }
    if(bf < -1) {
        if(key < K(R(n))) { // RL case
            R(n) = _rightRotate(R(n));
        }
        // else RR case
        return _leftRotate(n);
    }

    return n;
}
开发者ID:dannoy,项目名称:tools,代码行数:32,代码来源:avl.c

示例2: R

static struct avl_node *_leftRotate(struct avl_node *n)
{
    struct avl_node *t = R(n);

    R(n) = L(t);
    L(t) = n;

    // Calculate H(n) first
    H(n) = MAX(HH(n->left), HH(n->right)) + 1;
    H(t) = MAX(HH(t->left), HH(t->right)) + 1;

    return t;
}
开发者ID:dannoy,项目名称:tools,代码行数:13,代码来源:avl.c

示例3: if

static struct avl_node *_avl_delete(struct avl_node *n, int key)
{
    if(!n) return NULL;

    if(key < K(n)) L(n) = _avl_delete(L(n), key);
    else if(key > K(n)) R(n) = _avl_delete(R(n), key);
    else { // key == K(n)
        if(NULL == L(n) || NULL == R(n)) {
            struct avl_node *tmp = L(n) ? L(n) : R(n);
            if(tmp) {
                *n = *tmp; // copy contents of child to n
            }
            else { // n is leaf
                tmp = n;
                n = NULL;
            }
            free(tmp);
        }
        else { // two children case
            struct avl_node *d = _avl_minimum(n);
            K(n) = K(d);
            R(n) = _avl_delete(d, key);
        }

    }
    // no child case
    if(!n) return NULL;

    H(n) = MAX(HH(n->left), HH(n->right)) + 1;

    int bf = BF(n);

    if(bf > 1) {
        if(0 > BF(L(n))) { // LR case
            L(n) = _leftRotate(L(n));
        }
        // else LL case
        return _rightRotate(n);
    }
    if(bf < -1) {
        if(0 < BF(R(n))) { // RL case
            R(n) = _rightRotate(R(n));
        }
        // else RR case
        return _leftRotate(n);
    }
    
    
    return n;
}
开发者ID:dannoy,项目名称:tools,代码行数:50,代码来源:avl.c

示例4: KSPGMRESBuildSoln

static PetscErrorCode KSPGMRESBuildSoln(PetscScalar *nrs,Vec vs,Vec vdest,KSP ksp,PetscInt it)
{
  PetscScalar    tt;
  PetscErrorCode ierr;
  PetscInt       ii,k,j;
  KSP_GMRES      *gmres = (KSP_GMRES*)(ksp->data);

  PetscFunctionBegin;
  /* Solve for solution vector that minimizes the residual */

  /* If it is < 0, no gmres steps have been performed */
  if (it < 0) {
    ierr = VecCopy(vs,vdest);CHKERRQ(ierr); /* VecCopy() is smart, exists immediately if vguess == vdest */
    PetscFunctionReturn(0);
  }
  if (*HH(it,it) != 0.0) {
    nrs[it] = *GRS(it) / *HH(it,it);
  } else {
    ksp->reason = KSP_DIVERGED_BREAKDOWN;

    ierr = PetscInfo2(ksp,"Likely your matrix or preconditioner is singular. HH(it,it) is identically zero; it = %D GRS(it) = %G",it,PetscAbsScalar(*GRS(it)));CHKERRQ(ierr);
    PetscFunctionReturn(0);
  }
  for (ii=1; ii<=it; ii++) {
    k  = it - ii;
    tt = *GRS(k);
    for (j=k+1; j<=it; j++) tt = tt - *HH(k,j) * nrs[j];
    if (*HH(k,k) == 0.0) {
      ksp->reason = KSP_DIVERGED_BREAKDOWN;

      ierr = PetscInfo1(ksp,"Likely your matrix or preconditioner is singular. HH(k,k) is identically zero; k = %D",k);CHKERRQ(ierr);
      PetscFunctionReturn(0);
    }
    nrs[k] = tt / *HH(k,k);
  }

  /* Accumulate the correction to the solution of the preconditioned problem in TEMP */
  ierr = VecSet(VEC_TEMP,0.0);CHKERRQ(ierr);
  ierr = VecMAXPY(VEC_TEMP,it+1,nrs,&VEC_VV(0));CHKERRQ(ierr);

  ierr = KSPUnwindPreconditioner(ksp,VEC_TEMP,VEC_TEMP_MATOP);CHKERRQ(ierr);
  /* add solution to previous solution */
  if (vdest != vs) {
    ierr = VecCopy(vs,vdest);CHKERRQ(ierr);
  }
  ierr = VecAXPY(vdest,1.0,VEC_TEMP);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}
开发者ID:feelpp,项目名称:debian-petsc,代码行数:48,代码来源:gmres.c

示例5: KSPFGMRESBuildSoln

static PetscErrorCode KSPFGMRESBuildSoln(PetscScalar *nrs,Vec vguess,Vec vdest,KSP ksp,PetscInt it)
{
  PetscScalar    tt;
  PetscErrorCode ierr;
  PetscInt       ii,k,j;
  KSP_FGMRES     *fgmres = (KSP_FGMRES*)(ksp->data);

  PetscFunctionBegin;
  /* Solve for solution vector that minimizes the residual */

  /* If it is < 0, no fgmres steps have been performed */
  if (it < 0) {
    ierr = VecCopy(vguess,vdest);CHKERRQ(ierr); /* VecCopy() is smart, exists immediately if vguess == vdest */
    PetscFunctionReturn(0);
  }

  /* so fgmres steps HAVE been performed */

  /* solve the upper triangular system - RS is the right side and HH is
     the upper triangular matrix  - put soln in nrs */
  if (*HH(it,it) != 0.0) {
    nrs[it] = *RS(it) / *HH(it,it);
  } else {
    nrs[it] = 0.0;
  }
  for (ii=1; ii<=it; ii++) {
    k  = it - ii;
    tt = *RS(k);
    for (j=k+1; j<=it; j++) tt = tt - *HH(k,j) * nrs[j];
    nrs[k] = tt / *HH(k,k);
  }

  /* Accumulate the correction to the soln of the preconditioned prob. in
     VEC_TEMP - note that we use the preconditioned vectors  */
  ierr = VecSet(VEC_TEMP,0.0);CHKERRQ(ierr); /* set VEC_TEMP components to 0 */
  ierr = VecMAXPY(VEC_TEMP,it+1,nrs,&PREVEC(0));CHKERRQ(ierr);

  /* put updated solution into vdest.*/
  if (vdest != vguess) {
    ierr = VecCopy(VEC_TEMP,vdest);CHKERRQ(ierr);
    ierr = VecAXPY(vdest,1.0,vguess);CHKERRQ(ierr);
  } else { /* replace guess with solution */
    ierr = VecAXPY(vdest,1.0,VEC_TEMP);CHKERRQ(ierr);
  }
  PetscFunctionReturn(0);
}
开发者ID:ZJLi2013,项目名称:petsc,代码行数:46,代码来源:fgmres.c

示例6: KSPPGMRESBuildSoln

static PetscErrorCode KSPPGMRESBuildSoln(PetscScalar *nrs,Vec vguess,Vec vdest,KSP ksp,PetscInt it)
{
  PetscScalar    tt;
  PetscErrorCode ierr;
  PetscInt       k,j;
  KSP_PGMRES     *pgmres = (KSP_PGMRES*)(ksp->data);

  PetscFunctionBegin;
  /* Solve for solution vector that minimizes the residual */

  if (it < 0) {                                 /* no pgmres steps have been performed */
    ierr = VecCopy(vguess,vdest);CHKERRQ(ierr); /* VecCopy() is smart, exits immediately if vguess == vdest */
    PetscFunctionReturn(0);
  }

  /* solve the upper triangular system - RS is the right side and HH is
     the upper triangular matrix  - put soln in nrs */
  if (*HH(it,it) != 0.0) nrs[it] = *RS(it) / *HH(it,it);
  else nrs[it] = 0.0;

  for (k=it-1; k>=0; k--) {
    tt = *RS(k);
    for (j=k+1; j<=it; j++) tt -= *HH(k,j) * nrs[j];
    nrs[k] = tt / *HH(k,k);
  }

  /* Accumulate the correction to the solution of the preconditioned problem in TEMP */
  ierr = VecZeroEntries(VEC_TEMP);CHKERRQ(ierr);
  ierr = VecMAXPY(VEC_TEMP,it+1,nrs,&VEC_VV(0));CHKERRQ(ierr);
  ierr = KSPUnwindPreconditioner(ksp,VEC_TEMP,VEC_TEMP_MATOP);CHKERRQ(ierr);
  /* add solution to previous solution */
  if (vdest == vguess) {
    ierr = VecAXPY(vdest,1.0,VEC_TEMP);CHKERRQ(ierr);
  } else {
    ierr = VecWAXPY(vdest,1.0,VEC_TEMP,vguess);CHKERRQ(ierr);
  }
  PetscFunctionReturn(0);
}
开发者ID:feelpp,项目名称:debian-petsc,代码行数:38,代码来源:pgmres.c

示例7: KSPGMRESUpdateHessenberg

static PetscErrorCode KSPGMRESUpdateHessenberg(KSP ksp,PetscInt it,PetscBool hapend,PetscReal *res)
{
  PetscScalar *hh,*cc,*ss,tt;
  PetscInt    j;
  KSP_GMRES   *gmres = (KSP_GMRES*)(ksp->data);

  PetscFunctionBegin;
  hh = HH(0,it);
  cc = CC(0);
  ss = SS(0);

  /* Apply all the previously computed plane rotations to the new column
     of the Hessenberg matrix */
  for (j=1; j<=it; j++) {
    tt  = *hh;
    *hh = PetscConj(*cc) * tt + *ss * *(hh+1);
    hh++;
    *hh = *cc++ * *hh - (*ss++ * tt);
  }

  /*
    compute the new plane rotation, and apply it to:
     1) the right-hand-side of the Hessenberg system
     2) the new column of the Hessenberg matrix
    thus obtaining the updated value of the residual
  */
  if (!hapend) {
    tt = PetscSqrtScalar(PetscConj(*hh) * *hh + PetscConj(*(hh+1)) * *(hh+1));
    if (tt == 0.0) {
      ksp->reason = KSP_DIVERGED_NULL;
      PetscFunctionReturn(0);
    }
    *cc        = *hh / tt;
    *ss        = *(hh+1) / tt;
    *GRS(it+1) = -(*ss * *GRS(it));
    *GRS(it)   = PetscConj(*cc) * *GRS(it);
    *hh        = PetscConj(*cc) * *hh + *ss * *(hh+1);
    *res       = PetscAbsScalar(*GRS(it+1));
  } else {
    /* happy breakdown: HH(it+1, it) = 0, therfore we don't need to apply
            another rotation matrix (so RH doesn't change).  The new residual is
            always the new sine term times the residual from last time (GRS(it)),
            but now the new sine rotation would be zero...so the residual should
            be zero...so we will multiply "zero" by the last residual.  This might
            not be exactly what we want to do here -could just return "zero". */

    *res = 0.0;
  }
  PetscFunctionReturn(0);
}
开发者ID:feelpp,项目名称:debian-petsc,代码行数:50,代码来源:gmres.c

示例8: main

int main()
{
	
	FILE *out1;
	out1=fopen("out1Uniform.txt","w");
	
	// Parameters!!
	
	int Nr=1000;
	int Nt=1;
	
	
	HankelMatrix HH(Nr,200.);
	
	waveUniform w;
	w.initialize(HH);
	
	printf("%d\n",w.Nr);
	
	double r0=100.;
	for(int i=0;i<HH.Nr;i++)
	{
		w.phi[i]=exp(-(w.r[i]-r0)*(w.r[i]-r0)/0.5/0.5);
	}
	
	printf("%e\n",w.norm());
	w.normalize();
	printf("%e\n",w.norm());
	
	
	double dt=0.005;
	w.PrepareCrankArrays(dt);
	for (int ktime=0; ktime<1000; ktime++)
	{
		w.KineticPropCrankUniform(dt);
		
		if((ktime%10)==0)
		{
			for (int i=0; i<HH.Nr; i++)
				fprintf(out1,"%10.17e \n", w.r[i]*abs(w.phi[i]) ); //Save wave function multiply by rho axis
		}
		printf("%e\n",1.-w.norm());
	}
	
	
	
}
开发者ID:copilco,项目名称:balas,代码行数:47,代码来源:mainUniform.cpp

示例9: main

//using std;
int main()
{
	
	
	//complex I=complex(0.,1.);
	int N=1024;//50;
	int MM=12;//50;
	
	double R=.05;
	
	//Parametros para blas
	int lda=N;
	int ldb=1;
	int ldc=1;

	HankelMatrix HH(N,R);
	
	
}
开发者ID:copilco,项目名称:balas,代码行数:20,代码来源:HankelGSLAccelerateRows.cpp

示例10: KSPGMRESModifiedGramSchmidtOrthogonalization

PetscErrorCode  KSPGMRESModifiedGramSchmidtOrthogonalization(KSP ksp,PetscInt it)
{
  KSP_GMRES      *gmres = (KSP_GMRES*)(ksp->data);
  PetscErrorCode ierr;
  PetscInt       j;
  PetscScalar    *hh,*hes;

  PetscFunctionBegin;
  ierr = PetscLogEventBegin(KSP_GMRESOrthogonalization,ksp,0,0,0);CHKERRQ(ierr);
  /* update Hessenberg matrix and do Gram-Schmidt */
  hh  = HH(0,it);
  hes = HES(0,it);
  for (j=0; j<=it; j++) {
    /* (vv(it+1), vv(j)) */
    ierr   = VecDot(VEC_VV(it+1),VEC_VV(j),hh);CHKERRQ(ierr);
    KSPCheckDot(ksp,*hh);
    *hes++ = *hh;
    /* vv(it+1) <- vv(it+1) - hh[it+1][j] vv(j) */
    ierr = VecAXPY(VEC_VV(it+1),-(*hh++),VEC_VV(j));CHKERRQ(ierr);
  }
  ierr = PetscLogEventEnd(KSP_GMRESOrthogonalization,ksp,0,0,0);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}
开发者ID:masa-ito,项目名称:PETScToPoisson,代码行数:23,代码来源:borthog.c

示例11: tradeOneNightStand

function tradeOneNightStand() {

        vars Price = series(price());
        vars SMA10 = series(SMA(Price, 10));
        vars SMA40 = series(SMA(Price, 40));

        //Stop = 3 * 90 * PIP;

        var BuyStop,SellStop;

        BuyStop = HH(10) + 1*PIP;
        SellStop = LL(10) - 1*PIP;

        if (dow() == 5 && NumOpenLong == 0 && NumPendingLong == 0 && SMA10[0] > SMA40[0])
                enterLong(0,BuyStop);
        else if (dow() == 5 && NumOpenShort == 0 && NumPendingShort == 0 && SMA10[0] < SMA40[0])
                enterShort(0,SellStop);

        if (dow() != 5 && dow() != 6 && dow() != 7) {
                exitLong();
                exitShort();
        }

}
开发者ID:czarcrab,项目名称:Zorro,代码行数:24,代码来源:onc2.c

示例12: md4_process_block

void md4_process_block(uint32_t state[4], const uint32_t block[MD4_BLOCK_SIZE / 4])
{
    unsigned a, b, c, d;
    a = state[0];
    b = state[1];
    c = state[2];
    d = state[3];

    FF(a, b, c, d, block[0], 3);   /* 1 */
    FF(d, a, b, c, block[1], 7);   /* 2 */
    FF(c, d, a, b, block[2], 11);  /* 3 */
    FF(b, c, d, a, block[3], 19);  /* 4 */
    FF(a, b, c, d, block[4], 3);   /* 5 */
    FF(d, a, b, c, block[5], 7);   /* 6 */
    FF(c, d, a, b, block[6], 11);  /* 7 */
    FF(b, c, d, a, block[7], 19);  /* 8 */
    FF(a, b, c, d, block[8], 3);   /* 9 */
    FF(d, a, b, c, block[9], 7);   /* 10 */
    FF(c, d, a, b, block[10], 11); /* 11 */
    FF(b, c, d, a, block[11], 19); /* 12 */
    FF(a, b, c, d, block[12], 3);  /* 13 */
    FF(d, a, b, c, block[13], 7);  /* 14 */
    FF(c, d, a, b, block[14], 11); /* 15 */
    FF(b, c, d, a, block[15], 19); /* 16 */

    GG(a, b, c, d, block[0], 3);   /* 17 */
    GG(d, a, b, c, block[4], 5);   /* 18 */
    GG(c, d, a, b, block[8], 9);   /* 19 */
    GG(b, c, d, a, block[12], 13); /* 20 */
    GG(a, b, c, d, block[1], 3);   /* 21 */
    GG(d, a, b, c, block[5], 5);   /* 22 */
    GG(c, d, a, b, block[9], 9);   /* 23 */
    GG(b, c, d, a, block[13], 13); /* 24 */
    GG(a, b, c, d, block[2], 3);   /* 25 */
    GG(d, a, b, c, block[6], 5);   /* 26 */
    GG(c, d, a, b, block[10], 9);  /* 27 */
    GG(b, c, d, a, block[14], 13); /* 28 */
    GG(a, b, c, d, block[3], 3);   /* 29 */
    GG(d, a, b, c, block[7], 5);   /* 30 */
    GG(c, d, a, b, block[11], 9);  /* 31 */
    GG(b, c, d, a, block[15], 13); /* 32 */

    HH(a, b, c, d, block[0], 3);   /* 33 */
    HH(d, a, b, c, block[8], 9);   /* 34 */
    HH(c, d, a, b, block[4], 11);  /* 35 */
    HH(b, c, d, a, block[12], 15); /* 36 */
    HH(a, b, c, d, block[2], 3);   /* 37 */
    HH(d, a, b, c, block[10], 9);  /* 38 */
    HH(c, d, a, b, block[6], 11);  /* 39 */
    HH(b, c, d, a, block[14], 15); /* 40 */
    HH(a, b, c, d, block[1], 3);   /* 41 */
    HH(d, a, b, c, block[9], 9);   /* 42 */
    HH(c, d, a, b, block[5], 11);  /* 43 */
    HH(b, c, d, a, block[13], 15); /* 44 */
    HH(a, b, c, d, block[3], 3);   /* 45 */
    HH(d, a, b, c, block[11], 9);  /* 46 */
    HH(c, d, a, b, block[7], 11);  /* 47 */
    HH(b, c, d, a, block[15], 15); /* 48 */

    state[0] += a;
    state[1] += b;
    state[2] += c;
    state[3] += d;
}
开发者ID:WeijieH,项目名称:HashME,代码行数:64,代码来源:MD4.cpp

示例13: parse_ip_meta

void parse_ip_meta(FILE* w, u8* ip_meta, bool first) 
{
	char temp[256];

	const char* chm = (const char*)ip_meta;

	#define HH(ofs, len, name, first) { strncpy(temp, chm+ofs, len); temp[len]=0; for (int i=len-1; i>=0; i--) if(temp[i]==' ') temp[i]=0; else break; data_kvp(w, #name, temp, first);  }
	
	fprintf(w, "%s\"meta-info\": {\n", first?"\n":",\n");
	
	//data_kvp("type", "\"meta-info\"");

	HH(0x00,  16, hardwareId, true);
	HH(0x10,  16, makerId, false);
	
	HH(0x80, 128, productName, false);
	HH(0x4A,   6, productVersion, false);
	HH(0x50,  16, releaseDate, false);
	HH(0x40,  10, productId, false);
	HH(0x20,  16, discId, false);
	

	HH(0x30,   8, areas, false);
	HH(0x38,   8, peripherals, false);
	
	HH(0x60,  16, bootfile, false);
	HH(0x70,  16, publisher, false);

	fprintf(w, "\n}");
}
开发者ID:hean01,项目名称:reicast-emulator,代码行数:30,代码来源:main.cpp

示例14: ByteToUINT

void MD5::Transform(const uint8_t Block[64], int& error)
{
        uint32_t a = m_lMD5[0];
        uint32_t b = m_lMD5[1];
        uint32_t c = m_lMD5[2];
        uint32_t d = m_lMD5[3];

        uint32_t X[16];
        ByteToUINT( X, Block, 64, error);

        //Round 1 Transformation
        FF (a, b, c, d, X[ 0], MD5_S11, MD5_T01);
        FF (d, a, b, c, X[ 1], MD5_S12, MD5_T02);
        FF (c, d, a, b, X[ 2], MD5_S13, MD5_T03);
        FF (b, c, d, a, X[ 3], MD5_S14, MD5_T04);
        FF (a, b, c, d, X[ 4], MD5_S11, MD5_T05);
        FF (d, a, b, c, X[ 5], MD5_S12, MD5_T06);
        FF (c, d, a, b, X[ 6], MD5_S13, MD5_T07);
        FF (b, c, d, a, X[ 7], MD5_S14, MD5_T08);
        FF (a, b, c, d, X[ 8], MD5_S11, MD5_T09);
        FF (d, a, b, c, X[ 9], MD5_S12, MD5_T10);
        FF (c, d, a, b, X[10], MD5_S13, MD5_T11);
        FF (b, c, d, a, X[11], MD5_S14, MD5_T12);
        FF (a, b, c, d, X[12], MD5_S11, MD5_T13);
        FF (d, a, b, c, X[13], MD5_S12, MD5_T14);
        FF (c, d, a, b, X[14], MD5_S13, MD5_T15);
        FF (b, c, d, a, X[15], MD5_S14, MD5_T16);

        //Round 2 Transformation
        GG (a, b, c, d, X[ 1], MD5_S21, MD5_T17);
        GG (d, a, b, c, X[ 6], MD5_S22, MD5_T18);
        GG (c, d, a, b, X[11], MD5_S23, MD5_T19);
        GG (b, c, d, a, X[ 0], MD5_S24, MD5_T20);
        GG (a, b, c, d, X[ 5], MD5_S21, MD5_T21);
        GG (d, a, b, c, X[10], MD5_S22, MD5_T22);
        GG (c, d, a, b, X[15], MD5_S23, MD5_T23);
        GG (b, c, d, a, X[ 4], MD5_S24, MD5_T24);
        GG (a, b, c, d, X[ 9], MD5_S21, MD5_T25);
        GG (d, a, b, c, X[14], MD5_S22, MD5_T26);
        GG (c, d, a, b, X[ 3], MD5_S23, MD5_T27);
        GG (b, c, d, a, X[ 8], MD5_S24, MD5_T28);
        GG (a, b, c, d, X[13], MD5_S21, MD5_T29);
        GG (d, a, b, c, X[ 2], MD5_S22, MD5_T30);
        GG (c, d, a, b, X[ 7], MD5_S23, MD5_T31);
        GG (b, c, d, a, X[12], MD5_S24, MD5_T32);


        //Round 3 Transformation
        HH (a, b, c, d, X[ 5], MD5_S31, MD5_T33);
        HH (d, a, b, c, X[ 8], MD5_S32, MD5_T34);
        HH (c, d, a, b, X[11], MD5_S33, MD5_T35);
        HH (b, c, d, a, X[14], MD5_S34, MD5_T36);
        HH (a, b, c, d, X[ 1], MD5_S31, MD5_T37);
        HH (d, a, b, c, X[ 4], MD5_S32, MD5_T38);
        HH (c, d, a, b, X[ 7], MD5_S33, MD5_T39);
        HH (b, c, d, a, X[10], MD5_S34, MD5_T40);
        HH (a, b, c, d, X[13], MD5_S31, MD5_T41);
        HH (d, a, b, c, X[ 0], MD5_S32, MD5_T42);
        HH (c, d, a, b, X[ 3], MD5_S33, MD5_T43);
        HH (b, c, d, a, X[ 6], MD5_S34, MD5_T44);
        HH (a, b, c, d, X[ 9], MD5_S31, MD5_T45);
        HH (d, a, b, c, X[12], MD5_S32, MD5_T46);
        HH (c, d, a, b, X[15], MD5_S33, MD5_T47);
        HH (b, c, d, a, X[ 2], MD5_S34, MD5_T48);

        //Round 4 Transformation
        II (a, b, c, d, X[ 0], MD5_S41, MD5_T49);
        II (d, a, b, c, X[ 7], MD5_S42, MD5_T50);
        II (c, d, a, b, X[14], MD5_S43, MD5_T51);
        II (b, c, d, a, X[ 5], MD5_S44, MD5_T52);
        II (a, b, c, d, X[12], MD5_S41, MD5_T53);
        II (d, a, b, c, X[ 3], MD5_S42, MD5_T54);
        II (c, d, a, b, X[10], MD5_S43, MD5_T55);
        II (b, c, d, a, X[ 1], MD5_S44, MD5_T56);
        II (a, b, c, d, X[ 8], MD5_S41, MD5_T57);
        II (d, a, b, c, X[15], MD5_S42, MD5_T58);
        II (c, d, a, b, X[ 6], MD5_S43, MD5_T59);
        II (b, c, d, a, X[13], MD5_S44, MD5_T60);
        II (a, b, c, d, X[ 4], MD5_S41, MD5_T61);
        II (d, a, b, c, X[11], MD5_S42, MD5_T62);
        II (c, d, a, b, X[ 2], MD5_S43, MD5_T63);
        II (b, c, d, a, X[ 9], MD5_S44, MD5_T64);

        m_lMD5[0] += a;
        m_lMD5[1] += b;
        m_lMD5[2] += c;
        m_lMD5[3] += d;

}
开发者ID:BlueBrain,项目名称:TuvokBasics,代码行数:89,代码来源:MD5.cpp

示例15: load_le

/*
* MD5 Compression Function
*/
void MD5::compress_n(const byte input[], size_t blocks)
   {
   u32bit A = digest[0], B = digest[1], C = digest[2], D = digest[3];

   for(size_t i = 0; i != blocks; ++i)
      {
      load_le(&M[0], input, M.size());

      FF(A,B,C,D,M[ 0], 7,0xD76AA478);   FF(D,A,B,C,M[ 1],12,0xE8C7B756);
      FF(C,D,A,B,M[ 2],17,0x242070DB);   FF(B,C,D,A,M[ 3],22,0xC1BDCEEE);
      FF(A,B,C,D,M[ 4], 7,0xF57C0FAF);   FF(D,A,B,C,M[ 5],12,0x4787C62A);
      FF(C,D,A,B,M[ 6],17,0xA8304613);   FF(B,C,D,A,M[ 7],22,0xFD469501);
      FF(A,B,C,D,M[ 8], 7,0x698098D8);   FF(D,A,B,C,M[ 9],12,0x8B44F7AF);
      FF(C,D,A,B,M[10],17,0xFFFF5BB1);   FF(B,C,D,A,M[11],22,0x895CD7BE);
      FF(A,B,C,D,M[12], 7,0x6B901122);   FF(D,A,B,C,M[13],12,0xFD987193);
      FF(C,D,A,B,M[14],17,0xA679438E);   FF(B,C,D,A,M[15],22,0x49B40821);

      GG(A,B,C,D,M[ 1], 5,0xF61E2562);   GG(D,A,B,C,M[ 6], 9,0xC040B340);
      GG(C,D,A,B,M[11],14,0x265E5A51);   GG(B,C,D,A,M[ 0],20,0xE9B6C7AA);
      GG(A,B,C,D,M[ 5], 5,0xD62F105D);   GG(D,A,B,C,M[10], 9,0x02441453);
      GG(C,D,A,B,M[15],14,0xD8A1E681);   GG(B,C,D,A,M[ 4],20,0xE7D3FBC8);
      GG(A,B,C,D,M[ 9], 5,0x21E1CDE6);   GG(D,A,B,C,M[14], 9,0xC33707D6);
      GG(C,D,A,B,M[ 3],14,0xF4D50D87);   GG(B,C,D,A,M[ 8],20,0x455A14ED);
      GG(A,B,C,D,M[13], 5,0xA9E3E905);   GG(D,A,B,C,M[ 2], 9,0xFCEFA3F8);
      GG(C,D,A,B,M[ 7],14,0x676F02D9);   GG(B,C,D,A,M[12],20,0x8D2A4C8A);

      HH(A,B,C,D,M[ 5], 4,0xFFFA3942);   HH(D,A,B,C,M[ 8],11,0x8771F681);
      HH(C,D,A,B,M[11],16,0x6D9D6122);   HH(B,C,D,A,M[14],23,0xFDE5380C);
      HH(A,B,C,D,M[ 1], 4,0xA4BEEA44);   HH(D,A,B,C,M[ 4],11,0x4BDECFA9);
      HH(C,D,A,B,M[ 7],16,0xF6BB4B60);   HH(B,C,D,A,M[10],23,0xBEBFBC70);
      HH(A,B,C,D,M[13], 4,0x289B7EC6);   HH(D,A,B,C,M[ 0],11,0xEAA127FA);
      HH(C,D,A,B,M[ 3],16,0xD4EF3085);   HH(B,C,D,A,M[ 6],23,0x04881D05);
      HH(A,B,C,D,M[ 9], 4,0xD9D4D039);   HH(D,A,B,C,M[12],11,0xE6DB99E5);
      HH(C,D,A,B,M[15],16,0x1FA27CF8);   HH(B,C,D,A,M[ 2],23,0xC4AC5665);

      II(A,B,C,D,M[ 0], 6,0xF4292244);   II(D,A,B,C,M[ 7],10,0x432AFF97);
      II(C,D,A,B,M[14],15,0xAB9423A7);   II(B,C,D,A,M[ 5],21,0xFC93A039);
      II(A,B,C,D,M[12], 6,0x655B59C3);   II(D,A,B,C,M[ 3],10,0x8F0CCC92);
      II(C,D,A,B,M[10],15,0xFFEFF47D);   II(B,C,D,A,M[ 1],21,0x85845DD1);
      II(A,B,C,D,M[ 8], 6,0x6FA87E4F);   II(D,A,B,C,M[15],10,0xFE2CE6E0);
      II(C,D,A,B,M[ 6],15,0xA3014314);   II(B,C,D,A,M[13],21,0x4E0811A1);
      II(A,B,C,D,M[ 4], 6,0xF7537E82);   II(D,A,B,C,M[11],10,0xBD3AF235);
      II(C,D,A,B,M[ 2],15,0x2AD7D2BB);   II(B,C,D,A,M[ 9],21,0xEB86D391);

      A = (digest[0] += A);
      B = (digest[1] += B);
      C = (digest[2] += C);
      D = (digest[3] += D);

      input += hash_block_size();
      }
   }
开发者ID:BenjaminSchiborr,项目名称:safe,代码行数:55,代码来源:md5.cpp


注:本文中的HH函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。