• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ B2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: B0

void Bezier::recalc(QPointF p)
{
	// http://www.flong.com/texts/code/shapers_bez/
	// http://www.lemoda.net/maths/bezier-length/index.html,

	// arbitrary but reasonable t-values for interior control points
	double t0 = 0.3;
	double t1 = 0.7;

	if (m_drag_cp0) {
		double x = (p.x() - m_endpoint0.x() * B0(t0) - m_cp1.x() * B2(t0) - m_endpoint1.x() * B3(t0)) / B1(t0);
		double y = (p.y() - m_endpoint0.y() * B0(t0) - m_cp1.y() * B2(t0) - m_endpoint1.y() * B3(t0)) / B1(t0);
		m_cp0 = QPointF(x, y);
	}
	else {
		double x = (p.x() - m_endpoint0.x() * B0(t1) - m_cp0.x() * B1(t1) - m_endpoint1.x() * B3(t1)) /  B2(t1);
		double y = (p.y() - m_endpoint0.y() * B0(t1) - m_cp0.y() * B1(t1) - m_endpoint1.y() * B3(t1)) /  B2(t1);
		m_cp1 = QPointF(x, y);
	}
	
	/*
	DebugDialog::debug(QString("ix:%1 p0x:%2,p0y:%3 p1x:%4,p1y:%5 px:%6,py:%7")
							.arg(m_drag_cp0)
							.arg(m_endpoint0.x())
							.arg(m_endpoint0.y())
							.arg(m_endpoint1.x())
							.arg(m_endpoint1.y())
							.arg(p.x())
							.arg(p.y())
							);
	*/

	m_isEmpty = false;
}
开发者ID:honsey,项目名称:fztaxedit,代码行数:34,代码来源:bezier.cpp


示例2: ls_solve_od

mat ls_solve_od(const mat &A, const mat &B)
{
    int m=A.rows(), n=A.cols(), N=B.cols(), j;
    double beta;
    mat A2(A), B2(B), B3(n,N), submat, submat2;
    vec tmp(n), v;

//    it_assert1(m >= n, "The system is under-determined!");
    //it_assert1(m == B.rows(), "The number of rows in A must equal the number of rows in B!");

    // Perform a Householder QR factorization
    for (j=0; j<n; j++) {
	house(rvectorize(A2(j, m-1, j, j)), v, beta);
	v *= sqrt(beta);
	// 	submat.ref(A2, j,m-1, j,n-1);
 	submat = A2(j,m-1,j,n-1);
	sub_v_vT_m(submat, v);
	// 	submat.ref(B2, j,m-1, 0,N-1);
 	submat = B2(j,m-1,0,N-1);
	sub_v_vT_m(submat, v);
    }

    //    submat.ref(A2, 0,n-1,0,n-1);
    //    submat2.ref(B2, 0,n-1,0,N-1);
    submat = A2(0,n-1,0,n-1);
    submat2 = B2(0,n-1,0,N-1);
    for (j=0; j<N; j++) {
	backward_substitution(submat, submat2.get_col(j), tmp);
	B3.set_col(j, tmp);
    }
    
    return B3;
}
开发者ID:mbillingr,项目名称:tools4bci-unibuild,代码行数:33,代码来源:ls_solve.cpp


示例3: reallyroutespline

static int reallyroutespline (Pedge_t *edges, int edgen,
        Ppoint_t *inps, int inpn, Ppoint_t ev0, Ppoint_t ev1) {
    Ppoint_t p1, p2, cp1, cp2, p;
    Pvector_t v1, v2, splitv, splitv1, splitv2;
    double maxd, d, t;
    int maxi, i, spliti;

    static tna_t *tnas;
    static int tnan;

    if (tnan < inpn) {
        if (!tnas) {
            if (!(tnas = (tna_t *)malloc (sizeof (tna_t) * inpn)))
                return -1;
        } else {
            if (!(tnas = (tna_t *)realloc (tnas, sizeof (tna_t) * inpn)))
                return -1;
        }
        tnan = inpn;
    }
    tnas[0].t = 0;
    for (i = 1; i < inpn; i++)
        tnas[i].t = tnas[i - 1].t + dist (inps[i], inps[i - 1]);
    for (i = 1; i < inpn; i++)
        tnas[i].t /= tnas[inpn - 1].t;
    for (i = 0; i < inpn; i++) {
        tnas[i].a[0] = scale (ev0, B1 (tnas[i].t));
        tnas[i].a[1] = scale (ev1, B2 (tnas[i].t));
    }
    if (mkspline (inps, inpn, tnas, ev0, ev1, &p1, &v1, &p2, &v2) == -1)
        return -1;
    if (splinefits (edges, edgen, p1, v1, p2, v2, (inpn == 2 ? 1 : 0)))
        return 0;
    cp1 = add (p1, scale (v1, 1 / 3.0));
    cp2 = sub (p2, scale (v2, 1 / 3.0));
    for (maxd = -1, maxi = -1, i = 1; i < inpn - 1; i++) {
        t = tnas[i].t;
        p.x = B0 (t) * p1.x + B1 (t) * cp1.x +
                B2 (t) * cp2.x + B3 (t) * p2.x;
        p.y = B0 (t) * p1.y + B1 (t) * cp1.y +
                B2 (t) * cp2.y + B3 (t) * p2.y;
        if ((d = dist (p, inps[i])) > maxd)
            maxd = d, maxi = i;
    }
    spliti = maxi;
    splitv1 = normv (sub (inps[spliti], inps[spliti - 1]));
    splitv2 = normv (sub (inps[spliti + 1], inps[spliti]));
    splitv = normv (add (splitv1, splitv2));
    reallyroutespline (edges, edgen, inps, spliti + 1, ev0, splitv);
    reallyroutespline (edges, edgen, &inps[spliti], inpn - spliti, splitv, ev1);
    return 0;
}
开发者ID:crioux,项目名称:SpeedDemon-Profiler,代码行数:52,代码来源:route.cpp


示例4: B1

// Shortest cubic spline through 4 on-curve points(chord approximation)
void Bezier::FitSpline(Vec3 p[])
{
	// use chord length for shortest(best) cubic spline approximation
	float c3 = (p[1] - p[0]).Magnitude();
	float c2 = (p[2] - p[1]).Magnitude();
	float c1 = (p[3] - p[2]).Magnitude();

	// cases where p[1] is close to p[2] might lead to instabilities(need some heuristic)
	if (50 * c2 < c1 + c3)
	{
		p[1] = p[0] + (p[1] - p[0]) * 0.98;
		p[2] = p[3] + (p[2] - p[3]) * 0.98;
		c3 = c3 * 0.98;
		c2 = (p[2] - p[1]).Magnitude();
		c1 = c1 * 0.98;
	}

	float t1 = c1 / (c1 + c2 + c3);
	float t2 = (c1 + c2) / (c1 + c2 + c3);

	// Solve M * x = y
	float m00 = B1(t1);
	float m01 = B2(t1);
	float m10 = B1(t2);
	float m11 = B2(t2);

	float detM = m00 * m11 - m01 * m10;
	if (fabs(detM) > 1E-3)
	{
		// y = p - p0 * B0(t) - p3 * B3(t)
		Vec3 y1 = p[1] - p[0] * B0(t1) - p[3] * B3(t1);
		Vec3 y2 = p[2] - p[0] * B0(t2) - p[3] * B3(t2);

		// Minv
		float s = 1 / detM;
		float n00 = s * m11;
		float n01 = -s * m01;
		float n10 = -s * m10;
		float n11 = s * m00;

		// x = Minv * y
		Vec3 x1 = y1 * n00 + y2 * n01;
		Vec3 x2 = y1 * n10 + y2 * n11;

		p[1] = x1;
		p[2] = x2;
	}
}
开发者ID:Alexander-Eck,项目名称:vdrift,代码行数:49,代码来源:bezier.cpp


示例5: read_toc

int read_toc(unsigned char *buf, int *buflen, int mode)
{
  int result;
  int len,i,o;


  result=scsi_request("read_toc",buf,buflen,10,0,SCSIR_READ,
		      READTOC,0,0,0,0,0,
		      0,
		      B2(*buflen),
		      0);

  if (result || !mode) return result;

  len=V2(&buf[0]); 
  printf("\nTracks: %d \t (first=%02d last=%02d)\n",
	(buf[3]-buf[2])+1,buf[2],buf[3]);
  
  for (i=0;i<((len-2)/8)-1;i++) {
    o=4+i*8; /* offset to track descriptor */
    printf("Track %02d: %s (adr/ctrl=%02xh) begin=%06d end=%06d  "
           "length<=%06d\n",
	   i+1,(buf[o+1]&DATA_TRACK?"data ":"audio"),buf[o+1],V4(&buf[o+4]),
	   V4(&buf[o+4+8]),V4(&buf[o+4+8])-V4(&buf[o+4]) );

  }

  return result;
}
开发者ID:tjko,项目名称:readiso,代码行数:29,代码来源:readiso.c


示例6: rubikStep

void rubikStep(char *step)
{
	u8 m=0;
	for(m=0;step[m]!=0;m++)
	{
		switch(step[m])
		{
			case 7:allright90();break;
			case 11:F1();break;
			case 12:F2();break;
			case 13:F3();break;
			case 21:B1();break;
			case 22:B2();break;
			case 23:B3();break;
			case 31:R1();break;
			case 32:R2();break;
			case 33:R3();break;
			case 41:L1();break;
			case 42:L2();break;
			case 43:L3();break;
			case 51:U1();break;
			case 52:U2();break;
			case 53:U3();break;
			case 61:D1();break;
			case 62:D2();break;
			case 63:D3();break;
			default:break;
		}
	}
}
开发者ID:MrChang0,项目名称:rubik,代码行数:30,代码来源:mofang.c


示例7: f

void f(void) {
	int b1 = B1();
	if (b1) {
		int b2 = B2();
		if (b2) {
			B3();
		} else {
			B4();
		}
	}
	B5();
	while (B6()) {
		B12();
		int b14;
		do {
			B13();
			b14 = B14();
		} while(b14);
		B15();
	}
	int b7 = B7();
	if (b7 || B8()) {
		B9();
	}
	B10();
	B11();
}
开发者ID:decomp,项目名称:doc,代码行数:27,代码来源:sample.c


示例8: mode_sense10

int mode_sense10(unsigned char *buf, int *buflen)
{
  int len = *buflen;
  if (len >65000) len=65000;
  return scsi_request("mode_sense(10)",buf,buflen,10,0,SCSIR_READ,
		      MODESENSE10,0,0x01,0,0,0,0,B2(len),0);
}
开发者ID:tjko,项目名称:readiso,代码行数:7,代码来源:readiso.c


示例9: CPLSafeIntOverflow

inline CPLSafeInt<unsigned> operator*( const CPLSafeInt<unsigned>& A,
                                       const CPLSafeInt<unsigned>& B )
{
#ifdef BUILTIN_OVERFLOW_CHECK_AVAILABLE
    unsigned res;
    if( __builtin_umul_overflow(A.v(), B.v(), &res) )
        throw CPLSafeIntOverflow();
    return CPLSM(res);
#elif defined(_MSC_VER)
    msl::utilities::SafeInt<unsigned, CPLMSVCSafeIntException> A2(A.v());
    msl::utilities::SafeInt<unsigned, CPLMSVCSafeIntException> B2(B.v());
    return CPLSM(static_cast<unsigned>(A2 * B2));
#elif defined(CPL_HAS_GINT64)
    const unsigned a = A.v();
    const unsigned b = B.v();
    const GUInt64 res = static_cast<GUInt64>(a) * b;
    if( res > std::numeric_limits<unsigned>::max() )
    {
        throw CPLSafeIntOverflow();
    }
    return CPLSM(static_cast<unsigned>(res));
#else
    const unsigned a = A.v();
    const unsigned b = B.v();
    if( b > 0 && a > std::numeric_limits<unsigned>::max() / b )
        throw CPLSafeIntOverflow();
    return CPLSM(a*b);
#endif
}
开发者ID:OSGeo,项目名称:gdal,代码行数:29,代码来源:cpl_safemaths.hpp


示例10: inter_cone

void	inter_cone(t_caster *caster, t_object *cone)
{
  double	a;
  double	b;
  double	c;
  double	delt;

  init_temp_pos(caster, cone);
  a = A2(caster->temp_vec.x, caster->temp_vec.y, caster->temp_vec.z,
	 cone->data.angle);
  b = B2(caster->temp_vec.x, caster->temp_pos.x, caster->temp_vec.y,
	 caster->temp_pos.y, caster->temp_vec.z, caster->temp_pos.z,
	 cone->data.angle);
  c = C2(caster->temp_pos.x, caster->temp_pos.y, caster->temp_pos.z,
	 cone->data.angle);
  delt = (pow(b, 2.0) - 4.0 * (a * c));
  if (delt >= 0.0)
    {
      cone->dist = get_nearest((-b - sqrt(delt)) / (2.0 * a),
			       (-b + sqrt(delt)) / (2.0 * a));
      if (cone->dist > 0.0 && cone->dist < caster->intersection.dist)
	{
	  caster->intersection.brightness = cone->brightness;
	  init_intersection(caster, cone);
	  rotate_caster(caster, cone);
	}
    }
}
开发者ID:Sorikairo,项目名称:Raytracer,代码行数:28,代码来源:inter_object.c


示例11: rvec_priv_inst

static int
rvec_priv_inst( int dummy_rvec, ulong inst )
{
	int op, op_ext, b1, b2, b3;

	/* unhandled privileged instruction in supervisor mode */
	/* IMPORTANT: The GPRs are not available here! */

	op = OPCODE_PRIM( inst );
	op_ext = OPCODE_EXT( inst );
	b1 = B1( inst );	/* bit 6-10 */
	b2 = B2( inst );	/* bit 11-15 */
	b3 = B3( inst );	/* bit 16-20 */

	switch( OPCODE(op,op_ext) ) {
	case OPCODE( 31, 370 ):	/* tlbia (opt.) */
		/* not implemented on the 601,603,604,G3 (G4?) */
		break;
	case OPCODE( 31, 470 ):  /* dcbi rA,rB  -- rA=b2 rB=b3 */
		printm("dcbi treated as nop\n");
		mregs->nip += 4;
		return 0;
	default:
		printm("Unknown privileged instruction, opcode %lX\n", inst);
		stop_emulation();
		break;
	}
	mac_exception( 0x700, MOL_BIT(13) );
	return 0;
}
开发者ID:threader,项目名称:Mac-On-Linux,代码行数:30,代码来源:molcpu.c


示例12: A2

bool PGCicrcleTaskPt::CrossPoint(const ProjPt& prev, const ProjPt& next, ProjPt& optimized) {
    ProjPt A = prev - m_Center;
    ProjPt B = next - m_Center;
    ProjPt A2(A.m_X * A.m_X, A.m_Y * A.m_Y);
    ProjPt B2(B.m_X * B.m_X, B.m_Y * B.m_Y);
    double R2 = (m_Radius * m_Radius);

    bool PrevOutside = (A2.m_X + A2.m_Y) > R2;
    bool NextOutside = (B2.m_X + B2.m_Y) > R2;

    if (!PrevOutside && !NextOutside) {
        return false; // no cross point
    }

    ProjPt AB = B - A;

    double a = (AB.m_X * AB.m_X) + (AB.m_Y * AB.m_Y);
    double b = 2 * ((AB.m_X * A.m_X) + (AB.m_Y * A.m_Y));
    double c = A2.m_X + A2.m_Y - R2;

    double bb4ac = (b * b) -(4 * a * c);
    if (bb4ac < 0.0) {
        return false;
    }

    bool bCrossPoint = false;
    double k = 0.0;
    if (bb4ac == 0.0) {
        LKASSERT(a);
        // one point
        k = -b / (2 * a);
        bCrossPoint = true;
    }

    if (bb4ac > 0.0) {
        // Two point,
        if ((PrevOutside && m_bExit) || (!PrevOutside && NextOutside)) {
            LKASSERT(a);
            k = (-b + sqrt(bb4ac)) / (2 * a); // ouput : prev ouside && Exit TP || prev inside && next outside
            bCrossPoint = true;
        } else {
            LKASSERT(a);
            k = (-b - sqrt(bb4ac)) / (2 * a); // input : prev outside && Enter TP
            bCrossPoint = true;
        }
    }

    if (bCrossPoint) {
        ProjPt O = prev + ((next - prev) * k);
        if (dot_product((next - prev), O - prev) > 0.0 &&
                dot_product((prev - next), O - next) > 0.0) {
            optimized = O;
            return true;
        }
    }

    // no point
    return false;
}
开发者ID:rkalman,项目名称:LK8000,代码行数:59,代码来源:PGCicrcleTaskPt.cpp


示例13: genA0

Matrix genA0(Matrix &A,vector<long>&JROW,vector<long>&JCOL)
{
  long M = A.size();
  Matrix B(M), B2(M);
  forMatrix(A,i,j) B[JROW[i]-1][j]  = A[i][j];
  forMatrix(B,i,j) B2[i][JCOL[j]-1] = B[i][j];
  return B2;
}
开发者ID:tsukud-y,项目名称:estiva,代码行数:8,代码来源:genA0.cpp


示例14: main

int main()
{
	Rat a1(-1,2);
	Rat a2(2,9);
	Rat b2(3,2);
	Rat c1(-1,9);

	DoubleInterval A11(a2,b2);
	DoubleInterval A12(a1,0);
	DoubleInterval A21(-1,c1);
	DoubleInterval A22(a2,b2);

	DoubleMatrix A(2,2);
	A(0,0) = A11;
	A(0,1) = A12;
	A(1,0) = A21;
	A(1,1) = A22;

	DoubleInterval B1(1,3);
	DoubleInterval B2(3,4);

	DoubleVector b(2, (DoubleInterval)0);
	b[0] = B1;
	b[1] = B2;

	std::cout << A << std::endl;
	std::cout << b << std::endl;

	DoubleVector x(2, (DoubleInterval)0);
	x = A * b;

	std::cout << x << std::endl;

	//Need to sort this out
	DoubleInterval test(-1,2);
	DoubleInterval testb(5,100);

	DoubleInterval ans;
	ans = testb/test;

	std::cout << ans << std::endl;

	DoubleInterval k00(0,2);
	DoubleInterval k01(1,3);
	DoubleInterval k10(3,5);
	DoubleInterval k11(5,7);

	std::cout << "INVERSE IS " << std::endl;
	std::cout << boost::numeric::Doubleinterval_lib::multiplicative_inverse(k11) << std::endl;

	std::cout << boost::numeric::norm(k11) << std::endl;

	std::cout << k00 * k11 << std::endl;
	std::cout << k01 * k10 << std::endl;
	std::cout << (k00 * k11) - (k01 * k10) << std::endl;

	return 0;
}
开发者ID:kadirsekha,项目名称:MSc_Project,代码行数:58,代码来源:invtest.cpp


示例15: IRsense

uint8 IRsense(void){

    uint8 tmp;
    DIRIN(TRISD,BIT2);
    Nop();Nop();Nop();Nop();
    tmp=PORTD;
    DIROUT(TRISC,BIT2);


    switch(irsta){
   
        case 1:
            psta=0;
            B2(LATC)=0;
            if(irsense==1) {oncnt=0;irsta=2;}
          //  else {irsta=1;}
            break;

        case 2:
            oncnt++;
            if(oncnt>t1000) {irsta=3;}
            if(irsense==0) {irsta=1;}
            break;


        case 3:
            psta=1;
            B2(LATC)=1;
            if(irsense==0) {irsta=4;offcnt=0;}
            break;

        case 4:
            offcnt++;
            if(offcnt>t1000) {irsta=1;}
            if(irsense==1) {irsta=3;}
           
            break;

        default: irsta=1; break;

     
    }
    return irsta;
}
开发者ID:uwitec,项目名称:smartparking,代码行数:44,代码来源:IRsense.c


示例16: read_10

int read_10(int lba, int len, unsigned char *buf, int *buflen)
{
  return scsi_request("read_10",buf,buflen,10,0,SCSIR_READ,
		      READ10, 0,
		      B4(lba),
		      0,
		      B2(len),
		      0);

}
开发者ID:tjko,项目名称:readiso,代码行数:10,代码来源:readiso.c


示例17: main

int main()
{
	vector<float> A2(N*N);
	vector<float> B2(N*N);
	
	cout << "t4:" << endl;
	prob2_2_v2(A2, B2);
	cout << "-------" << endl;

	return 0;
}
开发者ID:pmendozav,项目名称:ucsp,代码行数:11,代码来源:p4.cpp


示例18: view

void CreateDoubleWayInteraction::paintEvent(QPaintEvent* /* anEvent */, QPainter& thePainter)
{
    if (R1 && (!R1->layer() || R1->isDeleted())) { // The roads were begon and then undoed. Restarting....
        HaveFirst = false;
        view()->setInteracting(false);
        R1 = R2 = NULL;
    }

    qreal rB = view()->pixelPerM()*DockData.RoadDistance->text().toDouble()/2;
    if (!HaveFirst)
    {
        thePainter.setPen(QColor(0,0,0));
        thePainter.drawEllipse(int(LastCursor.x()-rB),int(LastCursor.y()-rB),int(rB*2),int(rB*2));
    }
    else
    {
        Coord PreviousPoint;
        if (R1 && R1->size())
            PreviousPoint = PreviousPoints[R1->size()-1];
        else
            PreviousPoint = FirstPoint;

        if (distance(COORD_TO_XY(PreviousPoint), LastCursor) > 1)
        {
            qreal rA = FirstDistance * view()->pixelPerM()/2;
            LineF FA1(COORD_TO_XY(PreviousPoint),LastCursor);
            LineF FA2(FA1);
            LineF FB1(FA1);
            LineF FB2(FA1);
            FA1.slide(-rA);
            FA2.slide(rA);
            FB1.slide(-rB);
            FB2.slide(rB);
            QPointF A1(FA1.project(COORD_TO_XY(PreviousPoint)));
            QPointF A2(FA2.project(COORD_TO_XY(PreviousPoint)));
            QPointF B1(FB1.project(LastCursor));
            QPointF B2(FB2.project(LastCursor));

            QBrush SomeBrush(QColor(0xff,0x77,0x11,128));
            QPen TP(SomeBrush,view()->pixelPerM()*4);
            if (DockData.DriveRight->isChecked())
            {
                ::draw(thePainter,TP,Feature::OneWay, B1,A1,rB/4,view()->projection());
                ::draw(thePainter,TP,Feature::OneWay, A2,B2,rB/4,view()->projection());
            }
            else
            {
                ::draw(thePainter,TP,Feature::OneWay, A1,B1,rB/4,view()->projection());
                ::draw(thePainter,TP,Feature::OneWay, B2,A2,rB/4,view()->projection());
            }
        }
    }
}
开发者ID:chxyfish,项目名称:merkaartor,代码行数:53,代码来源:CreateDoubleWayInteraction.cpp


示例19: CAST5decrypt

void 
CAST5decrypt(const PGPUInt8 *in, PGPUInt8 *out, const PGPUInt32 *xkey)
{
	PGPUInt32 l, r, t;

	r = (PGPUInt32) in[0]<<24 | (PGPUInt32) in[1]<<16 | 
		(PGPUInt32) in[2]<<8 | in[3];

	l = (PGPUInt32) in[4]<<24 | (PGPUInt32) in[5]<<16 | 
		(PGPUInt32) in[6]<<8 | in[7];

	t = F1(l, xkey, 15); r ^= G1(t);
	t = F3(r, xkey, 14); l ^= G3(t);
	t = F2(l, xkey, 13); r ^= G2(t);
	t = F1(r, xkey, 12); l ^= G1(t);
	// Start here if only doing 12 rounds
	t = F3(l, xkey, 11); r ^= G3(t);
	t = F2(r, xkey, 10); l ^= G2(t);
	t = F1(l, xkey,  9); r ^= G1(t);
	t = F3(r, xkey,  8); l ^= G3(t);
	t = F2(l, xkey,  7); r ^= G2(t);
	t = F1(r, xkey,  6); l ^= G1(t);
	t = F3(l, xkey,  5); r ^= G3(t);
	t = F2(r, xkey,  4); l ^= G2(t);
	t = F1(l, xkey,  3); r ^= G1(t);
	t = F3(r, xkey,  2); l ^= G3(t);
	t = F2(l, xkey,  1); r ^= G2(t);
	t = F1(r, xkey,  0); l ^= G1(t);

	out[0]	= (PGPUInt8) B0(l);
	out[1]	= (PGPUInt8) B1(l);
	out[2]	= (PGPUInt8) B2(l);
	out[3]	= (PGPUInt8) B3(l);
	out[4]	= (PGPUInt8) B0(r);
	out[5]	= (PGPUInt8) B1(r);
	out[6]	= (PGPUInt8) B2(r);
	out[7]	= (PGPUInt8) B3(r);
}
开发者ID:ysangkok,项目名称:pgp-win32-6.5.8,代码行数:38,代码来源:Cast5.cpp


示例20: CAST5encrypt

/*
 * Encrypt the 8 bytes at *in into the 8 bytes at *out using the expanded
 * key schedule from *xkey.
 */
static void
CAST5encrypt(PGPByte const *in, PGPByte *out, PGPUInt32 const *xkey)
{
	PGPUInt32 l, r, t;

	l = (PGPUInt32)
		in[0]<<24 | (PGPUInt32)in[1]<<16 | (PGPUInt32)in[2]<<8 | in[3];
	r = (PGPUInt32)
		in[4]<<24 | (PGPUInt32)in[5]<<16 | (PGPUInt32)in[6]<<8 | in[7];

	t = F1(r, xkey,  0); l ^= G1(t);
	t = F2(l, xkey,  1); r ^= G2(t);
	t = F3(r, xkey,  2); l ^= G3(t);
	t = F1(l, xkey,  3); r ^= G1(t);
	t = F2(r, xkey,  4); l ^= G2(t);
	t = F3(l, xkey,  5); r ^= G3(t);
	t = F1(r, xkey,  6); l ^= G1(t);
	t = F2(l, xkey,  7); r ^= G2(t);
	t = F3(r, xkey,  8); l ^= G3(t);
	t = F1(l, xkey,  9); r ^= G1(t);
	t = F2(r, xkey, 10); l ^= G2(t);
	t = F3(l, xkey, 11); r ^= G3(t);
	/* Stop here if only doing 12 rounds */
	t = F1(r, xkey, 12); l ^= G1(t);
	t = F2(l, xkey, 13); r ^= G2(t);
	t = F3(r, xkey, 14); l ^= G3(t);
	t = F1(l, xkey, 15); r ^= G1(t);

	out[0] = B0(r);
	out[1] = B1(r);
	out[2] = B2(r);
	out[3] = B3(r);
	out[4] = B0(l);
	out[5] = B1(l);
	out[6] = B2(l);
	out[7] = B3(l);
}
开发者ID:ysangkok,项目名称:pgp-win32-6.5.8,代码行数:41,代码来源:pgpCAST5.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ B2_NOT_USED函数代码示例发布时间:2022-05-30
下一篇:
C++ B0函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap