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


C++ d1函数代码示例

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


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

示例1: test_transform_binary_async

void test_transform_binary_async(ExPolicy p, IteratorTag)
{
    typedef std::vector<int>::iterator base_iterator;
    typedef test::test_iterator<base_iterator, IteratorTag> iterator;

    std::vector<int> c1(10007);
    std::vector<int> c2(c1.size());
    std::vector<int> d1(c1.size()); //-V656
    std::iota(std::begin(c1), std::end(c1), std::rand());
    std::iota(std::begin(c2), std::end(c2), std::rand());

    auto f =
        hpx::parallel::transform(p,
            iterator(std::begin(c1)), iterator(std::end(c1)),
            std::begin(c2), std::begin(d1), add());
    f.wait();

    hpx::util::tuple<iterator, base_iterator, base_iterator> result = f.get();
    HPX_TEST(hpx::util::get<0>(result) == iterator(std::end(c1)));
    HPX_TEST(hpx::util::get<1>(result) == std::end(c2));
    HPX_TEST(hpx::util::get<2>(result) == std::end(d1));

    // verify values
    std::vector<int> d2(c1.size());
    std::transform(std::begin(c1), std::end(c1),
        std::begin(c2), std::begin(d2), add());

    std::size_t count = 0;
    HPX_TEST(std::equal(std::begin(d1), std::end(d1), std::begin(d2),
        [&count](int v1, int v2) -> bool {
            HPX_TEST_EQ(v1, v2);
            ++count;
            return v1 == v2;
        }));
    HPX_TEST_EQ(count, d2.size());
}
开发者ID:atrantan,项目名称:hpx,代码行数:36,代码来源:transform_binary_tests.hpp

示例2: d1

void Triangle<NNODES>::init(const std::vector<Point> &points)
{
    points_ = points;

    Triangle<NNODES> &t = *this;
    Point d1(t[1][0]-t[0][0], t[1][1]-t[0][1]);
    Point d2(t[2][0]-t[0][0], t[2][1]-t[0][1]);   //Point d2 = t[2] - t[0]; non funziona, reimplementare sottrazione

    M_J_(0,0) = d1[0];			// (x2-x1)
    M_J_(1,0) = d1[1];			// (y2-y1)
    M_J_(0,1) = d2[0];			// (x3-x1)
    M_J_(1,1) = d2[1];			// (y3-y1)

    detJ_ = M_J_(0,0) * M_J_(1,1) - M_J_(1,0) * M_J_(0,1);

    Real idet = 1. / detJ_;

    M_invJ_(0,0) =  idet * M_J_(1,1);	// (y3-y1)	-(x3-x1)
    M_invJ_(1,0) = -idet * M_J_(1,0);	// -(y2-y1) (x2-x1)
    M_invJ_(0,1) = -idet * M_J_(0,1);	//
    M_invJ_(1,1) =  idet * M_J_(0,0);	//	è la trasposta di quella della Sangalli (Ael)

    metric_ = M_invJ_ * M_invJ_.transpose();
}
开发者ID:laurasangalli,项目名称:rFEM,代码行数:24,代码来源:mesh_objects_imp.hpp

示例3: d0

double Trajectory::calcDirCoherence( const _2Real::Vec2 &p, double time, double dirTolerance ) const
{
	if( !this->canCalcDirCoherence() )
		throw _2Real::Exception( "cannot calc directional coherence -- not enough values" );

	_2Real::Vec2 d0( m_v1 - m_v0 );
	_2Real::Vec2 d1( p - m_v1 );

	double len0 = d0.norm();
	double len1 = d1.norm();

	double dt = time - m_prevTime;

	double compDir = 0.0;
	if( len0 * len1 > std::numeric_limits<double>::epsilon() )
	{
		if( len0 > dirTolerance && len1 > dirTolerance )
			compDir = ( 1.0 - ( d0.dot( d1 ) / ( len0 * len1 ) ) ) * 0.5f;
		else
			compDir = 0.5f;		//cannot make a decision -> tie value.
	}

	return compDir / ( dt * 30.0 );
}
开发者ID:anasancho,项目名称:_2RealFramework,代码行数:24,代码来源:FaceTracking.cpp

示例4: analyze


//.........这里部分代码省略.........
      for(Int_t k=0; k< 3;k++){
	truePidLc[i][j][k] =  new TH3D(Form("truePidLc%s%s%s",spec[i],spec[j],spec[k]),Form("#Lambda_{c}^{+} truePid for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.);
	truePidLcbar[i][j][k] =  new TH3D(Form("truePidLcbar%s%s%s",spec[i],spec[j],spec[k]),Form("#overline{#Lambda}_{c}^{-} truePid for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.);
      }

    }
  }

  trueKs =  new TH3D(Form("trueKs"),Form("K^{0*} true;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001);
  truePhi =  new TH2D(Form("truePhi"),Form("#phi true;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),100,0.98,1.05,40,0,10);

  trueLc =  new TH3D(Form("trueLc"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.);
  trueLcbar =  new TH3D(Form("trueLcbar"),Form("#overline{#Lambda}_{c}^{-} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1);

  mypidLc =  new TH3D(Form("mypidLc"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.);
  mypidLcbar =  new TH3D(Form("mypidLcbar"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.);

  // define particle types (particle type array)
  particle::AddParticleType("pi+",0.139,1); // 0
  particle::AddParticleType("pi-",0.139,-1); // 1
  particle::AddParticleType("K+",0.493,1); // 2 
  particle::AddParticleType("K-",0.493,-1); // 3
  particle::AddParticleType("p+",0.938,1); // 4 
  particle::AddParticleType("p-",0.938,-1); // 5
  particle::AddParticleType("K0*",0.896,0,5.05e-02); // 6
  particle::AddParticleType("K0bar*",0.896,0,5.05e-02); // 7
  particle::AddParticleType("Phi",1.02,0,0.00426); // 8
  particle::AddParticleType("Delta++",1.232,2,0.118); // 9 
  particle::AddParticleType("Delta--",1.232,-2,0.118);  // 10
  particle::AddParticleType("Lambdac+",2.28646,1,0.008); // 11
  particle::AddParticleType("Lambdacbar-",2.28646,-1,0.008); // 12
  particle::AddParticleType("Lambda1520",1.5195,-1,0.0000156); // 12

  particle d1("pi+");
  particle d2("K+");
  particle d3("p+");
  particle d4("pi-");
  particle d5("K-");
  particle d6("p-");

  particle prong1;
  particle prong2;
  particle prong3;

  particle polarKs("K0*");
  particle polarLc("Lambdac+");

  Int_t charge[] = {1,-1,1,-1,1,-1,0,0,0,2,-2,1,-1};

  particle ppos[20000];
  particle pneg[20000];

  Float_t weightsPos[20000][3];
  Float_t weightsNeg[20000][3];
  Int_t passMyPIDPos[20000][3];
  Int_t passMyPIDNeg[20000][3];

  Int_t npos=0;
  Int_t nneg=0;

  Float_t signal,signalTOF,signalTPC,pt,pz,phi,ptComb,ptComb3prong,invmass;
  Float_t ptd,pzd,phid;

  Float_t priors[3],prob[3];
  Float_t priors2[3][3],prob2[3][3];
  Float_t priors3[3][3][3],prob3[3][3][3];
开发者ID:noferini,项目名称:lessonmaterials,代码行数:67,代码来源:analyze3D.C

示例5: TrdtrmmUVar1

inline void
TrdtrmmUVar1( Orientation orientation, DistMatrix<F>& U )
{
#ifndef RELEASE
    PushCallStack("internal::TrdtrmmUVar1");
    if( U.Height() != U.Width() )
        throw std::logic_error("U must be square");
    if( orientation == NORMAL )
        throw std::logic_error("Orientation must be (conjugate-)transpose");
#endif
    const Grid& g = U.Grid();

    // Matrix views
    DistMatrix<F>
        UTL(g), UTR(g),  U00(g), U01(g), U02(g),
        UBL(g), UBR(g),  U10(g), U11(g), U12(g),
                         U20(g), U21(g), U22(g);
    DistMatrix<F,MD,STAR> d1(g);

    // Temporary distributions
    DistMatrix<F,MC,  STAR> S01_MC_STAR(g);
    DistMatrix<F,VC,  STAR> S01_VC_STAR(g);
    DistMatrix<F,VR,  STAR> U01_VR_STAR(g);
    DistMatrix<F,STAR,MR  > U01AdjOrTrans_STAR_MR(g);
    DistMatrix<F,STAR,STAR> U11_STAR_STAR(g);

    S01_MC_STAR.AlignWith( U );
    S01_VC_STAR.AlignWith( U );
    U01_VR_STAR.AlignWith( U );
    U01AdjOrTrans_STAR_MR.AlignWith( U );

    PartitionDownDiagonal
    ( U, UTL, UTR,
         UBL, UBR, 0 );
    while( UTL.Height() < U.Height() && UTL.Width() < U.Height() )
    {
        RepartitionDownDiagonal 
        ( UTL, /**/ UTR,  U00, /**/ U01, U02,
         /*************/ /******************/
               /**/       U10, /**/ U11, U12,
          UBL, /**/ UBR,  U20, /**/ U21, U22 );

        //--------------------------------------------------------------------//
        U11.GetDiagonal( d1 );
        S01_MC_STAR = U01;
        S01_VC_STAR = S01_MC_STAR;
        U01_VR_STAR = S01_VC_STAR;
        if( orientation == TRANSPOSE )
        {
            DiagonalSolve( RIGHT, NORMAL, d1, U01_VR_STAR );
            U01AdjOrTrans_STAR_MR.TransposeFrom( U01_VR_STAR );
        }
        else
        {
            DiagonalSolve( RIGHT, ADJOINT, d1, U01_VR_STAR );
            U01AdjOrTrans_STAR_MR.AdjointFrom( U01_VR_STAR );
        }
        LocalTrrk( UPPER, F(1), S01_MC_STAR, U01AdjOrTrans_STAR_MR, F(1), U00 );

        U11_STAR_STAR = U11;
        LocalTrmm
        ( RIGHT, UPPER, ADJOINT, UNIT, F(1), U11_STAR_STAR, U01_VR_STAR );
        U01 = U01_VR_STAR;

        LocalTrdtrmm( orientation, UPPER, U11_STAR_STAR );
        U11 = U11_STAR_STAR;
        //--------------------------------------------------------------------//
        d1.FreeAlignments();

        SlidePartitionDownDiagonal
        ( UTL, /**/ UTR,  U00, U01, /**/ U02,
               /**/       U10, U11, /**/ U12,
         /*************/ /******************/
          UBL, /**/ UBR,  U20, U21, /**/ U22 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
开发者ID:mcg1969,项目名称:Elemental,代码行数:79,代码来源:UVar1.hpp

示例6: a


//.........这里部分代码省略.........

				
		//Store the Axis in Undistorted Images in Folder
		std::stringstream fileNameAxisUnDistortUsingFnOutput;
		fileNameAxisUnDistortUsingFnOutput << IMG_OUT_AXIS_DRAWING << "savasci_doshi_Undistort_WithFn" << i << ".jpg";
		cv::imwrite(fileNameAxisUnDistortUsingFnOutput.str(),udImUsingFn);

		 
		//Without Function Call	
		cv::Mat tvecs31= tvecs[i];

		//cv::Mat rvecs33;
		cv::Rodrigues(rvecs[i],rvecs33);
		
		cv::Mat extrinsic = (cv::Mat_<double>(3, 4) <<	rvecs33.at<double>(0,0), rvecs33.at<double>(0,1), rvecs33.at<double>(0,2), tvecs31.at<double>(0),
														rvecs33.at<double>(1,0), rvecs33.at<double>(1,1), rvecs33.at<double>(1,2), tvecs31.at<double>(1),
														rvecs33.at<double>(2,0), rvecs33.at<double>(2,1), rvecs33.at<double>(2,2), tvecs31.at<double>(2));
		
		cv::Mat instrinsic=cameraMatrix;

		cv::Mat P=instrinsic*extrinsic;

		//Drawing the 3 coordinate axis
		cv::Mat p1 = (cv::Mat_<double>(4, 1) << 0,0,0,1);
		cv::Mat imagep1=P*p1;

		cv::Mat p2 = (cv::Mat_<double>(4, 1) << 4,0,0,1);
		cv::Mat imagep2=P*p2;

		cv::Mat p3 = (cv::Mat_<double>(4, 1) << 0,4,0,1);
		cv::Mat imagep3=P*p3;
				
		cv::Mat p4 = (cv::Mat_<double>(4, 1) << 0,0,4,1);
		cv::Mat imagep4=P*p4;

		cv::Mat im = cv::imread(filelist[i]);

		cv::Point2d o1(imagep1.at<double>(0)/imagep1.at<double>(2),imagep1.at<double>(1)/imagep1.at<double>(2));
		cv::Point2d x1(imagep2.at<double>(0)/imagep2.at<double>(2),imagep2.at<double>(1)/imagep2.at<double>(2));
		cv::Point2d y1(imagep3.at<double>(0)/imagep3.at<double>(2),imagep3.at<double>(1)/imagep3.at<double>(2));
		cv::Point2d z1(imagep4.at<double>(0)/imagep4.at<double>(2),imagep4.at<double>(1)/imagep4.at<double>(2));


		cv::line(im, o1, x1, CV_RGB(0, 0, 255), 3, 8, 0);
		cv::line(im, o1, y1, CV_RGB(0, 255, 0), 3, 8, 0);
		cv::line(im, o1, z1, CV_RGB(255, 0, 0), 3, 8, 0);
		
		//Drawing the cube
		cv::Mat rectp1 = P*(cv::Mat_<double>(4, 1) << 0,0,0,1);
		cv::Mat rectp2 = P*(cv::Mat_<double>(4, 1) << 0,2,2,1);
		cv::Mat rectp3 = P*(cv::Mat_<double>(4, 1) << 2,0,2,1);
		cv::Mat rectp4 = P*(cv::Mat_<double>(4, 1) << 2,2,0,1);

		cv::Mat rectp5 = P*(cv::Mat_<double>(4, 1) << 2,0,0,1);
		cv::Mat rectp6 = P*(cv::Mat_<double>(4, 1) << 0,0,2,1);
		cv::Mat rectp7 = P*(cv::Mat_<double>(4, 1) << 0,2,0,1);
		cv::Mat rectp8 = P*(cv::Mat_<double>(4, 1) << 2,2,2,1);
		
		cv::Point2d a1(rectp1.at<double>(0)/rectp1.at<double>(2),rectp1.at<double>(1)/rectp1.at<double>(2));
		cv::Point2d b1(rectp2.at<double>(0)/rectp2.at<double>(2),rectp2.at<double>(1)/rectp2.at<double>(2));
		cv::Point2d c1(rectp3.at<double>(0)/rectp3.at<double>(2),rectp3.at<double>(1)/rectp3.at<double>(2));
		cv::Point2d d1(rectp4.at<double>(0)/rectp4.at<double>(2),rectp4.at<double>(1)/rectp4.at<double>(2));
		cv::Point2d e1(rectp5.at<double>(0)/rectp5.at<double>(2),rectp5.at<double>(1)/rectp5.at<double>(2));
		cv::Point2d f1(rectp6.at<double>(0)/rectp6.at<double>(2),rectp6.at<double>(1)/rectp6.at<double>(2));
		cv::Point2d g1(rectp7.at<double>(0)/rectp7.at<double>(2),rectp7.at<double>(1)/rectp7.at<double>(2));
		cv::Point2d h1(rectp8.at<double>(0)/rectp8.at<double>(2),rectp8.at<double>(1)/rectp8.at<double>(2));
				
		cv::line(im, a1, e1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, a1, f1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, a1, g1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, e1, c1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, e1, d1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, g1, b1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, g1, d1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, f1, b1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, f1, c1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, h1, b1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, h1, c1, CV_RGB(0, 255, 255), 1, 8, 0);
		cv::line(im, h1, d1, CV_RGB(0, 255, 255), 1, 8, 0);

		//cv::rectangle(im, a1, b1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(im, a1, c1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(im, a1, d1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(im, b1, c1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(im, b1, d1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(im, c1, d1, CV_RGB(0, 255, 255), 1, 8, 0);

		//cv::rectangle(udIm, a1, b1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(udIm, a1, c1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(udIm, a1, d1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(udIm, b1, c1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(udIm, b1, d1, CV_RGB(0, 255, 255), 1, 8, 0);
		//cv::rectangle(udIm, c1, d1, CV_RGB(0, 255, 255), 1, 8, 0);
		
		//Store the Axis in Original Images in Folder
		std::stringstream fileNameAxisOriginalOutput;
		fileNameAxisOriginalOutput << IMG_OUT_AXIS_DRAWING << "savasci_doshi_Original_WithoutFn" << i << ".jpg";
		cv::imwrite(fileNameAxisOriginalOutput.str(),im);
	}
}
开发者ID:seckin206,项目名称:OpenCV-learning,代码行数:101,代码来源:CameraCalibrator.cpp

示例7: main

int  main( int  argc, char ** argv )
{
    // 1. Angle brackets handling bug
    // As of now a2, a3 and a4 will be skipped

    int  a1 = i < 7 ? i : 7;
    int  a2 = 8;
    int  a3 = 9;
    int  a4 = p->data;
    int  a5 = 8;


    // 2. Function pointer decl bug
    // As of now a6 will be skipped

    int ( *a6 )( int, char ** ) = &main;


    // 3. Wrong prototype will be written
    // As of now prototype will be ( SomeType ( p )( int ) )

    int  a7( short ( *p )( int ) );


    // 4. DECL_IGNORE bug
    // As of now a8 will be skipped

    if ( argc > 0 )
        return 0;

    short a8 = i;


    // 5. Local variables support
	// As of now all the identifiers below are either reported as prototypes,
	// or not recognized at all
	// The comments on the right specify which kind of tag should be generated

    const char *b1( "uuu" );                //variable
    int b2( int ooo, const char* o );       //prototype
    int b3( int( 7 ) );                     //variable
    int c1( a >> ooo );                     //variable
    int c2( int * h );                      //prototype
    int c3( std::map<int>( 9 ) );           //variable
    int c4( std::map<int> a );              //prototype
    int c5( map<int>  & a );                //prototype
    int c6( ooo & a );                      //prototype
    int c7( int & a );                      //prototype
    int c8( map<int> a );                   //prototype
    int c9( int a );                        //prototype
    ind d1( a * 2 );                        //variable
    ind d2( "a" * 2 );                      //variable
    int d3( *j );                           //variable
    int f1( SomeType (*p)( int ) );         //prototype
    SomeType (*f2)( int o );                //variable
    int f3( std::map<int> & a );            //prototype
    int g1( SomeType a );                   //prototype
	// As of now, the signature of h1 will be "( int a = R )",
	// 'R' is to be replaced by something clearer to denote a
	// string literal
    char h1( const char *a = "a" );         //prototype
    int h2();                               //prototype
    char h3( double );                      //prototype
    int h4( h u );                          //prototype
    int (*p1)( int o );                     //variable
    int v4( iii( 'o' ) );                   //variable
    int v5( iii( o ) );                     //variable
    int v6( int (*p)( int ) );              //prototype
    int v7( 89 );                           //variable
    int v8( ooo );                          //variable
    // __ARGS(x) is a compatibility macro which optionally
	// expands to x when prototypes are supported, so
	// w1 should be parsed as a prototype
    int w1 __ARGS (( int a ));              //prototype
    int w2 (( a - 5 ) / 6 );                //variable
    int x1( a.b );                          //variable
    int x2( a->b );                         //variable
    int x3( NS::a  b );                     //prototype
    int x4( a ^ b );                        //variable 
    int x5( a ^ 6 );                        //variable
    int x6( a | b );                        //variable
	// As of now, x7 is not recognized at all; it should
	// give a variable tag but it's tricky to get it
	// right because of '&' which suggests a prototype,
	// so for now let's just ignore it
    //int x7( a & b & c );                  //variable
    int x8( a & b & 2 );                    //variable
    int x9( a && b );                       //variable
}
开发者ID:Monits,项目名称:ctags,代码行数:89,代码来源:input.cpp

示例8: main

int main()
{
	// test if two ints are equal or not
	cout << "***  Integers Tests  ***" << endl;

	int leftInts[4] = { 1, 2, -1, -1 }; // lhs integers used for testing equality
	int rightInts[4] = { 1, 4, 1, -1 }; // rhs integers used for testing equality
	for (int a = 0; a < 4; a++)
	{
		cout << "Integers: " << leftInts[a] << " and " << rightInts[a] << " are "
			<< (isEqualTo(leftInts[a], rightInts[a]) ? "equal" : "\"NOT\" equal") << '\n';
	}

	// test if two chars are equal or not
	cout << "\n\n***  Chars Tests  ***" << endl;
	char leftChars[4] = { 'a', 'a', 'c', 'c' }; // lhs chars used for testing equality
	char rightChars[4] = { 'a', 'c', 'a', 'c' }; // rhs chars used for testing equality
	for (int a = 0; a < 4; a++)
	{
		cout << "Characters: " << leftChars[a] << " and " << rightChars[a] << " are "
			<< (isEqualTo(leftChars[a], rightChars[a]) ? "equal" : "\"NOT\" equal") << '\n';
	}

	// test if two doubles are equal or not
	cout << "\n\n***  Double Tests  ***" << endl;
	double leftDoubles[4] = { 2.2, 2.2, -2.2, -2.2 }; // lhs integers used for testing equality
	double rightDoubles[4] = { 2.2, 2.3, 2.2, -2.2 }; // rhs integers used for testing equality
	for (int a = 0; a < 4; a++)
	{
		cout << "Double numbers: " << leftDoubles[a] << " and " << rightDoubles[a] << " are "
			<< (isEqualTo(leftDoubles[a], rightDoubles[a]) ? "equal" : "\"NOT\" equal") << '\n';
	}

	// test if two Complex objects are equal
	cout << "\n\n***  Complex Tests  ***" << endl;
	Complex a(10, 5); // Complex objects used
	Complex a1(10, 5); // for testing equality
	cout << "Class objects: " << a << " and " << a1 << " are "
		<< (isEqualTo(a, a1) ? "equal" : "\"NOT\" equal");

	Complex b(10, 5); // Complex objects used
	Complex b1(10, 54); // for testing equality
	cout << "\nClass objects: " << b << " and " << b1 << " are "
		<< (isEqualTo(b, b1) ? "equal" : "\"NOT\" equal");

	Complex c(10, -5); // Complex objects used
	Complex c1(10, 5); // for testing equality
	cout << "\nClass objects: " << c << " and " << c1 << " are "
		<< (isEqualTo(c, c1) ? "equal" : "\"NOT\" equal");

	Complex d(-10, -5); // Complex objects used
	Complex d1(-10, -5); // for testing equality
	cout << "\nClass objects: " << d << " and " << d1 << " are "
		<< (isEqualTo(d, d1) ? "equal" : "\"NOT\" equal");

	//test if two strings are equal or not
	cout << "\n\n\n***  String Tests  ***" << endl;
	string leftStrings[4] = { "abcdefg", "abcdefg", "-abcdefg", "-abcdefg" }; // lhs chars used for testing equality
	string rightStrings[4] = { "abcdefg", "abcdefh", "abcdefg", "-abcdefg" }; // rhs chars used for testing equality
	for (int a = 0; a < 4; a++)
	{
		cout << "String objects: " << leftStrings[a] << " and " << rightStrings[a] << " are "
			<< (isEqualTo(leftStrings[a], rightStrings[a]) ? "equal" : "\"NOT\" equal") << '\n';
	}

	//test if two dates are equal or not
	cout << "\n\n***  Date Tests  ***";
	Date dayA(2, 31, 2016); // create date object
	Date dayB(2, 31, 2016); // create date object
	cout << "\nDate objects: " << dayA << " and " << dayB << " are "
		<< (isEqualTo(dayA, dayB) ? "equal" : "\"NOT\" equal");

	Date dayC(-2, 13, 2016); // create date object
	Date dayD(2, 14, 2016); // create date object
	cout << "\nDate objects: " << dayC << " and " << dayD << " are "
		<< (isEqualTo(dayC, dayD) ? "equal" : "\"NOT\" equal");

	Date dayE(-2, 13, 2016); // create date object
	Date dayF(2, 13, 2016); // create date object
	cout << "\nDate objects: " << dayE << " and " << dayF << " are "
		<< (isEqualTo(dayE, dayF) ? "equal" : "\"NOT\" equal");

	Date dayG(-2, 13, 2016); // create date object
	Date dayH(2, 31, 2016); // create date object
	cout << "\nDate objects: " << dayG << " and " << dayH << " are "
		<< (isEqualTo(dayG, dayH) ? "equal" : "\"NOT\" equal") << '\n';

	cout << endl << endl;
	return 0;
} // end main
开发者ID:PrufessorOak,项目名称:CISP400V9A6,代码行数:90,代码来源:CISP400V9A6.cpp

示例9: main

int main (int argc, char** argv)
{

int lives=3;

  int width = 1400;
  int height = 715;
  int numBlocks;

  points=10;
  /*float v[][6] = {
    2.5, -8.6, 3, 0.5,0,1,
    4, -7, 1, 4,0,1,
    5.5, -8.6, 3, 0.5,0,1,
    2.5, -5.5, 2, 1,1,1,
    4, -5.5, 2, 1,1,1,

    5.5, -5.5, 2, 1,1,1,
    4, -9.5, 2.5, 1.5, 2,2,
    4, -10.5, 1, 4, 0, 3,
    9, -9, 4, 4, 0, 3
  };*/


  GLFWwindow* window = initGLFW(width, height);

 initGL (window, width, height);
 float tm=glfwGetTime();
  elements e;
  while (glfwGetTime()-tm<=5 and mode==0)
  {
    e.menu();
    glfwSwapBuffers(window);
    glfwPollEvents();
  //  cout<<mode;  
  }

if(mode==0)
  mode=1;

if(mode==1){
  numBlocks= 12;
  groundLevel=-15;
}

dummy d1(0-2,12);

dummy d2(4-2,12);

dummy d3(8-2,12);
float v1[][6] = {
    2, -9.5-3, 3, 0.5,0,3,
    5, -9-3, 4, 0.5,0,3,

    8, -8.5-3, 5, 0.5,0,3,
    11, -8-3, 6, 0.5,0,3,
    
    2, -8-3, 1, 2,0,1,
    5, -7.0-3, 1, 2,0,1,
    
    8, -6.0-3, 1, 2,0,1,
    11, -5-3, 1, 2,0,1,
    
    2, -7-3, 1, 1,0,2,
    5, -6.0-3, 1, 1,0,2,
    
    8, -5.0, 1, 1,0,2,
    11, -4, 1, 1,0,2,
    
   // 2, -8+6, 1, 2,0,1,
    //5, -7+6, 1, 2,0,1,
    
   // 2,-8+9,1,1,0,2,
    //5, -7+9, 1, 1,0,2
};

if(mode==2)
{
  numBlocks=14;
  groundLevel=-15;
  
}


    float v2[][6] = {
    //0,-14.5,5,3,0,3,//hill
    //0,-11,1,1,1,4,//ball
    //7.5,groundLevel+4*2,1,5,0,1,
    2+4, -9.5-3, 3, 0.5,0,3,
    5+4, -9-3, 4, 0.5,0,3,
    8+4, -8.5-3, 5, 0.5,0,3,
    11+4, -8-3, 6, 0.5,0,3,
    
    2+4, -8-3, 1, 2,0,1,
    5+4, -7.0-3, 1, 2,0,1,
    
    8+4, -6.0-3, 1, 2,0,1,
    11+4, -5-3, 1, 2,0,1,

    2+4, -7-3, 1, 1,0,2,
//.........这里部分代码省略.........
开发者ID:bhaktipriya,项目名称:Angry-Birds,代码行数:101,代码来源:main.cpp

示例10: strike

 Real AnalyticTwoAssetBarrierEngine::put() const {
     CumulativeNormalDistribution nd;
     return strike()*std::exp(-riskFreeRate()*residualTime())*nd(-d2())-underlying1()*nd(-d1());
 }
开发者ID:21hub,项目名称:QuantLib,代码行数:4,代码来源:analytictwoassetbarrierengine.cpp

示例11: d1

 Real AnalyticTwoAssetBarrierEngine::d3() const {
     return d1()+ (2*rho()*std::log(barrier()/underlying2()))/(volatility2()*std::sqrt(residualTime()));
 }
开发者ID:21hub,项目名称:QuantLib,代码行数:3,代码来源:analytictwoassetbarrierengine.cpp

示例12: collide

// Collision detection for rotated rectangles
k3d::vec2 collide(k3d::vec2 pos1, const k3d::vec2 & hw1, const k3d::vec2 & v1,
                  const k3d::vec2 & pos2, const k3d::vec2 & hw2, const k3d::vec2 & v2, bool & collided)
{
    k3d::vec2 vn1(-v1.y, v1.x);
    k3d::vec2 a1((pos1 + (hw1.x*v1)) - (hw1.y*vn1));
    k3d::vec2 b1((pos1 + (hw1.x*v1)) + (hw1.y*vn1));
    k3d::vec2 c1((pos1 - (hw1.x*v1)) + (hw1.y*vn1));
    k3d::vec2 d1((pos1 - (hw1.x*v1)) - (hw1.y*vn1));

    k3d::vec2 vn2(-v2.y, v2.x);
    k3d::vec2 a2((pos2 + (hw2.x*v2)) - (hw2.y*vn2));
    k3d::vec2 b2((pos2 + (hw2.x*v2)) + (hw2.y*vn2));
    k3d::vec2 c2((pos2 - (hw2.x*v2)) + (hw2.y*vn2));
    k3d::vec2 d2((pos2 - (hw2.x*v2)) - (hw2.y*vn2));

    collided = true;

    if (intersect(a1, b1, a2, b2)) {
        // TODO check if it is enough to go back that distance for the 1st 2 cases (corners) here
        if (intersect(a1, b1, b2, c2)) { //corner
            return pos1 + dist_point_to_line(b2, a1, b1)*((v2 + vn2).normalize());
        }
        if (intersect(a1, b1, a2, d2)) { //corner
            return pos1 + dist_point_to_line(a2, a1, b1)*((v2 - vn2).normalize());
        }
        if (intersect(b1, c1, a2, b2)) {
            return pos1 + dist_point_to_line(b1, a2, b2)*v2;
        }
        if (intersect(a1, d1, a2, b2)) {
            return pos1 + dist_point_to_line(a1, a2, b2)*v2;
        }
        if (intersect(b1, c1, a2, d2)) {
            //return pos1 + a2 - b1; // MAYBE THIS IS BETTER ?
            // FIXME max is actually incorrect here, it should be a weighted sum based on where a2b2 intersects a1b1
            return pos1 - max(dist_point_to_line(a1, a2, d2), dist_point_to_line(b1, a2, d2))*vn2;
        }
        if (intersect(a1, d1, b2, c2)) {
            // FIXME max is actually incorrect here, it should be a weighted sum based on where a2b2 intersects a1b1
            return pos1 + max(dist_point_to_line(a1, b2, c2), dist_point_to_line(b1, b2, c2))*vn2;
        }
    }

    if (intersect(a1, b1, b2, c2)) {
        // a1,b1 and a2,b2 already covered
        // TODO check if it is enough to go back that distance for the 1st case here (corner)
        if (intersect(a1, b1, c2, d2)) { //corner
            return pos1 + dist_point_to_line(c2, a1, b1)*((vn2-v2).normalize());
        }
        if (intersect(b1, c1, b2, c2)) {
            return pos1 + dist_point_to_line(b1, b2, c2)*vn2;
        }
        if (intersect(a1, d1, b2, c2)) {
            return pos1 + dist_point_to_line(a1, b2, c2)*vn2;
        }
        if (intersect(b1, c1, a2, b2)) {
            // FIXME max is actually incorrect here, it should be a weighted sum based on where b2c2 intersects a1b1
            return pos1 + max(dist_point_to_line(b1, a2, b2), dist_point_to_line(a1, a2, b2))*v2;
        }
        if (intersect(a1, d1, c2, d2)) {
            // FIXME max is actually incorrect here, it should be a weighted sum based on where b2c2 intersects a1b1
            return pos1 - max(dist_point_to_line(b1, c2, d2), dist_point_to_line(a1, c2, d2))*v2;
        }
    }

    if (intersect(a1, b1, c2, d2)) {
        // a1,b1 and b2,c2 already covered
        // TODO check if it is enough to go back that distance for the 1st case here (corner)
        if (intersect(a1, b1, a2, d2)) {
            return pos1 + dist_point_to_line(d2, a1, b1)*((-1.0*v2)-vn2);
        }
        if (intersect(b1, c1, c2, d2)) {
            return pos1 - dist_point_to_line(b1, c2, d2)*v2;
        }
        if (intersect(a1, d1, c2, d2)) {
            return pos1 - dist_point_to_line(a1, c2, d2)*v2;
        }
        if (intersect(b1, c1, b2, c2)) {
            // FIXME see above fixme's
            return pos1 + max(dist_point_to_line(b1, b2, c2), dist_point_to_line(a1, b2, c2))*vn2;
        }
        if (intersect(a1, d1, a2, d2)) {
            // FIXME see above fixme's
            return pos1 - max(dist_point_to_line(a1, d2, a2), dist_point_to_line(b1, d2, a2))*vn2;
        }
    }

    if (intersect(a1, b1, d2, a2)) {
        // a1,b1 and c2,d2 already covered and a1,b1 and a2,b2 also already covered
        if (intersect(b1, c1, d2, a2)) {
            return pos1 - dist_point_to_line(b1, d2, a2)*vn2;
        }
        if (intersect(a1, d1, d2, a2)) {
            return pos1 - dist_point_to_line(a1, d2, a2)*vn2;
        }
        if (intersect(b1, c1, c2, d2)) {
            // FIXME see above fixme's
            return pos1 - max(dist_point_to_line(b1, c2, d2), dist_point_to_line(a1, c2, d2))*v2;
        }
        if (intersect(a1, d1, a2, b2)) {
//.........这里部分代码省略.........
开发者ID:karshan,项目名称:libtanks,代码行数:101,代码来源:collide.cpp

示例13: test_objects


//.........这里部分代码省略.........
				TEST(d.x==4  && d.y==5);
				TEST(tmp=="baz");
				std::set<std::string> tg=tr.detach();
				TEST(tg.size()==2);
				TEST(tg.count("foo")==1);
				TEST(tg.count("dat")==1);
			}
		}
		cache().clear();
		{
			std::cout << "-- Without Triggers" << std::endl;
			{
				cache().reset();
				cppcms::triggers_recorder tr(cache());
				mydata d(1,2);
				cache().store_frame("foo","bar",std::set<std::string>(),-1,true);
				cache().store_data("dat",d,std::set<std::string>(),-1,true);
				TEST(tr.detach().size()==0);
			}
			{
				cache().reset();
				cppcms::triggers_recorder tr(cache());
				mydata d;
				std::string tmp;
				TEST(cache().fetch_frame("foo",tmp,true));
				TEST(cache().fetch_data("dat",d,true));
				TEST(d.x==1  && d.y==2);
				TEST(tmp=="bar");
				TEST(tr.detach().size()==0);
			}
			{
				cache().reset();
				cppcms::triggers_recorder tr(cache());
				mydata d;
				std::string tmp;
				TEST(cache().fetch_frame("foo",tmp));
				TEST(cache().fetch_data("dat",d));
				TEST(d.x==1  && d.y==2);
				TEST(tmp=="bar");
				TEST(tr.detach().size()==2);
			}
			{
				cache().reset();
				cppcms::triggers_recorder tr(cache());
				mydata d(4,5);
				cache().store_frame("foo","baz",-1,true);
				cache().store_data("dat",d,-1,true);
				TEST(tr.detach().size()==0);
			}
			{
				cache().reset();
				cppcms::triggers_recorder tr(cache());
				mydata d;
				std::string tmp;
				TEST(cache().fetch_frame("foo",tmp,true));
				TEST(cache().fetch_data("dat",d,true));
				TEST(d.x==4  && d.y==5);
				TEST(tmp=="baz");
				TEST(tr.detach().size()==0);
			}
		}
		cache().clear();
		{
			std::cout << "-- Timeouts" << std::endl;
			{
				cache().reset();
				mydata d1(1,2);
				mydata d2(4,5);
				cache().store_frame("foo1","baz1",std::set<std::string>(),2,true);
				cache().store_data("dat1",d1,std::set<std::string>(),2,true);
				cache().store_frame("foo2","baz2",2,true);
				cache().store_data("dat2",d2,2,true);
			}
			{
				cache().reset();
				mydata d1,d2;
				std::string t1,t2;
				TEST(cache().fetch_frame("foo1",t1,true));
				TEST(cache().fetch_frame("foo2",t2,true));
				TEST(cache().fetch_data("dat1",d1,true));
				TEST(cache().fetch_data("dat2",d2,true));
				TEST(d1.x==1  && d1.y==2);
				TEST(d2.x==4  && d2.y==5);
				TEST(t1=="baz1");
				TEST(t2=="baz2");
			}
			booster::ptime::millisleep(3000);
			{
				cache().reset();
				mydata d1,d2;
				std::string t1,t2;
				TEST(!cache().fetch_frame("foo1",t1,true));
				TEST(!cache().fetch_frame("foo2",t2,true));
				TEST(!cache().fetch_data("dat1",d1,true));
				TEST(!cache().fetch_data("dat2",d2,true));
			}
		}


	}
开发者ID:klupek,项目名称:cppcms,代码行数:101,代码来源:cache_frontend_test.cpp

示例14: gradeSum

/// The top three entries on the stack are two digits to add and their
/// proported sum mod 10. Transmit Y/N to indicate whether or not the
/// sum is correct. If the sum is not correct, transmit the correct
/// sum. Update the weights to bias future random number selection.
void gradeSum(MorseToken) {
  if (2 < symbolStackSize()) {
    uint8_t s1(s(1).m2i());
    uint8_t s2(s(2).m2i());
    uint8_t s0(s(0).toChar());
    uint8_t sum((s1 + s2) % 10);
    Serial.print(s2);
    Serial.print(" ");
    Serial.print(s1);
    Serial.print(" ");
    Serial.print(s0);
    Serial.print(" sum: ");
    Serial.println(sum);
    bool correct(s(0).m2i() == sum);
    if (correct) {
      txString("Y");
      // Decrease the error counts associated with the digits the user
      // just added incorrectly, taking care not to underflow.
      uint8_t d1(!!digitErr[s1]);
      uint8_t d2(!!digitErr[s2]);
      digitErr[s1] -= d1; 
      digitErr[s2] -= d2;
      digitErrCount -= (d1 + d2);
      Serial.print("Decrementing ");
      Serial.print(s1);
      Serial.print(". New weight is: ");
      Serial.println(digitErr[s1]);
      Serial.print("Decrementing ");
      Serial.print(s2);
      Serial.print(". New weight is: ");
      Serial.println(digitErr[s2]);
    } else {
      //            012345678901
      char buffer[] = "N  a + b = c";
      buffer[3] = s2 + '0';
      buffer[7] = s1 + '0';
      buffer[11] = sum + '0';
      txString(buffer);
      // Increase the error counts associated with the digits the user
      // just added incorrectly, taking care not to overflow.
      uint8_t d1(3 * (digitErr[s1] - 3 < 255));
      uint8_t d2(3 * (digitErr[s2] - 3 < 255));
      digitErr[s1] += d1;
      digitErr[s2] += d2;
      digitErrCount += d1 + d2;
      Serial.print("Incrementing ");
      Serial.print(s1);
      Serial.print(". New weight is: ");
      Serial.println(digitErr[s1]);
      Serial.print("Incrementing ");
      Serial.print(s2);
      Serial.print(". New weight is: ");
      Serial.println(digitErr[s2]);
    }
    // If the user plays long enough without a reset to saturate two
    // of the digits chosen at random, divide all the error counts
    // by 2.
    if (digitErr[s1] == 255 && digitErr[s2] == 255) {
      for (uint8_t i(0); i < 10; ++i) {
	digitErr[i] <<= 1;
      }
      digitErrCount <<= 1;
      Serial.println("Halving all weights.");
    }
    Serial.print("Digit error count is: ");
    Serial.println(digitErrCount);
    popN(3);
  } else {
    txError();
  }
}
开发者ID:pictographer,项目名称:didah,代码行数:75,代码来源:pda.cpp

示例15: d1

Node *OutlineVectorizer::findOtherSide(Node *node)
{
	DataPixel *pix = node->m_pixel;

	TPoint dir = -computeGradient(pix);
	if (dir == TPoint(0, 0))
		return 0;
	TPoint d1(tsign(dir.x), 0), d2(0, tsign(dir.y));
	int num = abs(dir.y), den = abs(dir.x);
	if (num > den) {
		tswap(d1, d2);
		tswap(num, den);
	}
	TPoint pos = pix->m_pos;
	int i;
	for (i = 0;; i++) {
		TPoint q(pos.x + d1.x * i + d2.x * num * i / den, pos.y + d1.y * i + d2.y * num * i / den);
		DataPixel *nextPix = m_dataRaster->pixels(q.y) + q.x;
		if (nextPix->m_ink == false)
			break;
		pix = nextPix;
	}
	assert(pix);
	if (!pix->m_node) {
		const int wrap = m_dataRaster->getWrap();
		if (pix[-1].m_node)
			pix--;
		else if (pix[1].m_node)
			pix++;
		else if (pix[wrap].m_node)
			pix += wrap;
		else if (pix[-wrap].m_node)
			pix -= wrap;
		else {
			assert(0);
		}
	}
	if (!pix->m_node)
		return 0;
	Node *q = pix->m_node;
	while (q->m_pixel == 0 && q->m_other)
		q = q->m_other;
	assert(q && q->m_pixel == pix);

	for (i = 0; i < 5; i++) {
		if (!q->m_prev)
			break;
		q = q->m_prev;
	}

	Node *best = q;
	double bestDist2 = computeDistance2(q, node);
	for (i = 0; i < 10; i++) {
		q = q->m_next;
		if (!q)
			break;
		double dist2 = computeDistance2(q, node);
		if (dist2 < bestDist2) {
			bestDist2 = dist2;
			best = q;
		}
	}

	return best;
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:65,代码来源:toutlinevectorizer.cpp


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