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


C++ engine函数代码示例

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


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

示例1: main

int main(int argc,char *argv[])
{
	int opt;
	PsimagLite::String file("");
	SizeType total=0;
	RealType offset = 0;
	SizeType site3 = 0;

	RealType step = 0;
	while ((opt = getopt(argc, argv, "f:p:t:o:i:")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		case 'p':
			site3 = atoi(optarg);
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}
	if (file=="") throw std::runtime_error("Wrong usage\n");

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,geometryParams.sites);
	PsimagLite::Vector<SizeType>::Type sites;
	GeometryParamsType::readVector(sites,file,"TSPSites");
	sites.resize(3);
	sites[2] = site3;
	SizeType nthreads = 1;

	try {
		GeometryParamsType::readLabel(nthreads,file,"Threads=");
	} catch (std::exception& e) {}

	assert(nthreads>0);

	typedef PsimagLite::Concurrency ConcurrencyType;
	ConcurrencyType concurrency(&argc,&argv,nthreads);

	SizeType dof = 2; // spin up and down

	GeometryLibraryType geometry(geometryParams);

	std::cerr<<geometry;
	
	EngineType engine(geometry.matrix(),dof,false);

	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	bool verbose = false;

	
	RealType sum = 0;
	for (SizeType i=0;i<electronsUp;i++) sum += engine.eigenvalue(i);
	std::cerr<<"Energy="<<dof*sum<<"\n";

	SizeType sigma3 = 0;

	std::cout<<"#sites= ";
	for (SizeType i=0;i<sites.size();i++) std::cout<<sites[i]<<" ";
	std::cout<<"\n";

	typedef FreeFermions::ParallelHolonDoublon<RealType,FieldType,EngineType> ParallelHolonDoublonType;
	typedef PsimagLite::Parallelizer<ParallelHolonDoublonType> ParallelizerType;
	ParallelizerType threadedHolonDoublon(PsimagLite::Concurrency::npthreads,
	                                      PsimagLite::MPI::COMM_WORLD);

	ParallelHolonDoublonType::HolonDoublonParamsType params(ne,
															sites,
															sigma3,
															offset,
															step,
															debug,
															verbose);
	ParallelHolonDoublonType helperHolonDoublon(engine,params);

	FieldType superdensity = helperHolonDoublon.calcSuperDensity(sites[0],sites[1]);
	std::cout<<"#superdensity="<<superdensity<<"\n";

	threadedHolonDoublon.loopCreate(total,helperHolonDoublon);
}
开发者ID:anocera,项目名称:FreeFermions,代码行数:95,代码来源:HolonDoublon.cpp

示例2: engine

	QScriptValue Mouse::position() const
	{
		return Point::constructor(mMouseDevice.cursorPosition(), engine());
	}
开发者ID:WeDo30,项目名称:actiona,代码行数:4,代码来源:mouse.cpp

示例3: engine

uint64_t IERandom::Int()
{
	return engine();
}
开发者ID:yalcinerbora,项目名称:GIThesis,代码行数:4,代码来源:IERandom.cpp

示例4: return

double IERandom::Double01()
{
	return (static_cast<double>(engine()) / std::mt19937_64::max());
}
开发者ID:yalcinerbora,项目名称:GIThesis,代码行数:4,代码来源:IERandom.cpp

示例5: assert

uint64_t IERandom::IntMV(uint64_t mean, uint64_t variance)
{
	assert(mean + variance <= std::mt19937_64::max());
	assert(mean - variance >= std::mt19937_64::min());
	return static_cast<uint64_t>(((static_cast<double>(engine()) / std::mt19937_64::max()) * 2 * variance)) + mean - variance;
}
开发者ID:yalcinerbora,项目名称:GIThesis,代码行数:6,代码来源:IERandom.cpp

示例6: americanSwaption

void americanSwaption(
	boost::shared_ptr<LiborForwardModel> & lfm,
	boost::shared_ptr<IborIndex> & libor,
	utilities::csvBuilder & file) {

	Date pricingDate =									// pricing date
		Settings::instance().evaluationDate();

	Date optionStart = libor->fixingCalendar().advance(	// start in 2 days
		pricingDate, 
		Period(2, Days));
	
	Date optionEnd(16, July, 2016);
	Date fwdMaturity(16, July, 2021);

	//Date optionEnd = libor->fixingCalendar().advance(	// start in 2 days
	//	optionStart,
	//	Period(6, Months));

	//Date fwdMaturity = optionStart + Period(3, Years);	// underlying 3 years

	Schedule schedule(
		optionStart,
		fwdMaturity, 
		libor->tenor(), 
		libor->fixingCalendar(),
		ModifiedFollowing, 
		ModifiedFollowing, 
		DateGeneration::Backward, 
		false);

	Rate swapRate = 0.0404;								// dummy swap rate

	boost::shared_ptr<VanillaSwap> forwardSwap(
		new VanillaSwap(VanillaSwap::Receiver, 100.0,
		schedule, swapRate, ActualActual(),
		schedule, libor, 0.0, libor->dayCounter()));

	forwardSwap->setPricingEngine(boost::shared_ptr<PricingEngine>(
		new DiscountingSwapEngine(libor->forwardingTermStructure())));

	swapRate = forwardSwap->fairRate();					// obtain the fair rate

	forwardSwap = boost::shared_ptr<VanillaSwap>(		// rebuild the "right" swap
		new VanillaSwap(VanillaSwap::Receiver, 100.0,
		schedule, swapRate, ActualActual(),
		schedule, libor, 0.0, libor->dayCounter()));
	forwardSwap->setPricingEngine(boost::shared_ptr<PricingEngine>(
		new DiscountingSwapEngine(libor->forwardingTermStructure())));

	boost::shared_ptr<PricingEngine> engine(
		new LfmSwaptionEngine(lfm,
		libor->forwardingTermStructure()));
	boost::shared_ptr<Exercise> exercise(
		new AmericanExercise(optionEnd));

	boost::shared_ptr<Swaption> americanSwaption(		// create the swaption
		new Swaption(forwardSwap, exercise));
	americanSwaption->setPricingEngine(engine);

	Real npv = americanSwaption->NPV();
	
	std::cout << "American swaption npv: "											// information
			  << npv
			  << std::endl;
			  
}
开发者ID:vermosen,项目名称:LiborModel,代码行数:67,代码来源:americanSwaption.cpp

示例7: engine

QScriptValue post_data_list_class::newInstance(const http_data_list &pdl)
{
	QScriptValue data = engine()->newVariant(QVariant::fromValue(pdl));
	return engine()->newObject(this, data);
}
开发者ID:jadderbao,项目名称:http-post-test,代码行数:5,代码来源:http_script_engine.cpp

示例8: componentDisconnected

 void componentDisconnected()
 {
     CPPUNIT_ASSERT(engine());
     engine()->stop(0);
 }
开发者ID:ptka,项目名称:DSI,代码行数:5,代码来源:CMultipleResponsesTest.cpp

示例9: ATRACE_CALL

void Layer::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const
{
    ATRACE_CALL();

    if (CC_UNLIKELY(mActiveBuffer == 0)) {
        // the texture has not been created yet, this Layer has
        // in fact never been drawn into. This happens frequently with
        // SurfaceView because the WindowManager can't know when the client
        // has drawn the first time.

        // If there is nothing under us, we paint the screen in black, otherwise
        // we just skip this update.

        // figure out if there is something below us
        Region under;
        const SurfaceFlinger::LayerVector& drawingLayers(
                mFlinger->mDrawingState.layersSortedByZ);
        const size_t count = drawingLayers.size();
        for (size_t i=0 ; i<count ; ++i) {
            const sp<Layer>& layer(drawingLayers[i]);
            if (layer.get() == static_cast<Layer const*>(this))
                break;
            under.orSelf( hw->getTransform().transform(layer->visibleRegion) );
        }
        // if not everything below us is covered, we plug the holes!
        Region holes(clip.subtract(under));
        if (!holes.isEmpty()) {
            clearWithOpenGL(hw, holes, 0, 0, 0, 1);
        }
        return;
    }

    // Bind the current buffer to the GL texture, and wait for it to be
    // ready for us to draw into.
    status_t err = mSurfaceFlingerConsumer->bindTextureImage();
    if (err != NO_ERROR) {
        ALOGW("onDraw: bindTextureImage failed (err=%d)", err);
        // Go ahead and draw the buffer anyway; no matter what we do the screen
        // is probably going to have something visibly wrong.
    }

    bool canAllowGPU = false;
#ifdef QCOM_BSP
    if(isProtected()) {
        char property[PROPERTY_VALUE_MAX];
        if ((property_get("persist.gralloc.cp.level3", property, NULL) > 0) &&
                (atoi(property) == 1)) {
            canAllowGPU = true;
        }
    }
#endif

    bool blackOutLayer = isProtected() || (isSecure() && !hw->isSecure());

    RenderEngine& engine(mFlinger->getRenderEngine());

    if (!blackOutLayer || (canAllowGPU)) {
        // TODO: we could be more subtle with isFixedSize()
        const bool useFiltering = getFiltering() || needsFiltering(hw) || isFixedSize();

        // Query the texture matrix given our current filtering mode.
        float textureMatrix[16];
        mSurfaceFlingerConsumer->setFilteringEnabled(useFiltering);
        mSurfaceFlingerConsumer->getTransformMatrix(textureMatrix);

        if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) {

            /*
             * the code below applies the display's inverse transform to the texture transform
             */

            // create a 4x4 transform matrix from the display transform flags
            const mat4 flipH(-1,0,0,0,  0,1,0,0, 0,0,1,0, 1,0,0,1);
            const mat4 flipV( 1,0,0,0, 0,-1,0,0, 0,0,1,0, 0,1,0,1);
            const mat4 rot90( 0,1,0,0, -1,0,0,0, 0,0,1,0, 1,0,0,1);

            mat4 tr;
            uint32_t transform = hw->getOrientationTransform();
            if (transform & NATIVE_WINDOW_TRANSFORM_ROT_90)
                tr = tr * rot90;
            if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_H)
                tr = tr * flipH;
            if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_V)
                tr = tr * flipV;

            // calculate the inverse
            tr = inverse(tr);

            // and finally apply it to the original texture matrix
            const mat4 texTransform(mat4(static_cast<const float*>(textureMatrix)) * tr);
            memcpy(textureMatrix, texTransform.asArray(), sizeof(textureMatrix));
        }

        // Set things up for texturing.
        mTexture.setDimensions(mActiveBuffer->getWidth(), mActiveBuffer->getHeight());
        mTexture.setFiltering(useFiltering);
        mTexture.setMatrix(textureMatrix);

        engine.setupLayerTexturing(mTexture);
    } else {
//.........这里部分代码省略.........
开发者ID:trebon-chocodot,项目名称:android_frameworks_native,代码行数:101,代码来源:Layer.cpp

示例10: TEST

    TEST( RocksEngineTest, DropDirect1 ) {
        std::string path = "/tmp/mongo-rocks-engine-test";
        boost::filesystem::remove_all( path );
        RocksEngine engine( path );

        {
            MyOperationContext opCtx( &engine );
            Status status = engine.createCollection( &opCtx,
                                                     "test.foo",
                                                     CollectionOptions() );
            ASSERT_OK( status );
        }

        {
            MyOperationContext opCtx( &engine );
            Status status = engine.createCollection( &opCtx,
                                                     "test.bar",
                                                     CollectionOptions() );
            ASSERT_OK( status );
        }

        {
            MyOperationContext opCtx( &engine );
            Status status = engine.createCollection( &opCtx,
                                                     "silly.bar",
                                                     CollectionOptions() );
            ASSERT_OK( status );
        }

        {
            std::list<std::string> names;
            engine.getCollectionNamespaces( "test", &names );
            ASSERT_EQUALS( 2U, names.size() );
        }

        {
            std::list<std::string> names;
            engine.getCollectionNamespaces( "silly", &names );
            ASSERT_EQUALS( 1U, names.size() );
        }

        {
            MyOperationContext opCtx( &engine );
            Status status = engine.dropCollection( &opCtx,
                                                   "test.foo" );
            ASSERT_OK( status );
        }

        {
            std::list<std::string> names;
            engine.getCollectionNamespaces( "test", &names );
            ASSERT_EQUALS( 1U, names.size() );
            ASSERT_EQUALS( names.front(), "test.bar" );
        }

        {
            MyOperationContext opCtx( &engine );
            Status status = engine.dropCollection( &opCtx,
                                                   "test.foo" );
            ASSERT_NOT_OK( status );
        }
    }
开发者ID:li--paul,项目名称:mongo,代码行数:62,代码来源:rocks_engine_test.cpp

示例11: engine

QScriptValue ArrayBufferClass::newInstance(const QByteArray& ba) {
    QScriptValue data = engine()->newVariant(QVariant::fromValue(ba));
    return engine()->newObject(this, data);
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:4,代码来源:ArrayBufferClass.cpp

示例12: main


//.........这里部分代码省略.........
                           case 'P':		/* parseable output?          */
				if ( !parsedef(opts.optarg) )
					prusage(pmProgname);

				vis.show_samp = parseout;
				break;

                           case 'L':		/* line length                */
				if ( !numeric(opts.optarg) )
					prusage(pmProgname);

				linelen = atoi(opts.optarg);
				break;

			   default:		/* gather other flags */
				flaglist[i++] = c;
			}
		}

		/*
		** get optional interval-value and optional number of samples	
		*/
		if (opts.optind < argc && opts.optind < MAXFL)
		{
			char	*endnum, *arg;

			arg = argv[opts.optind++];
			if (pmParseInterval(arg, &opts.interval, &endnum) < 0)
			{
				pmprintf(
			"%s: %s option not in pmParseInterval(3) format:\n%s\n",
					pmProgname, arg, endnum);
				free(endnum);
				opts.errors++;
			}
			else
				interval = opts.interval;
	
			if (opts.optind < argc)
			{
				arg = argv[opts.optind];
				if (!numeric(arg))
					prusage(pmProgname);
				if ((opts.samples = atoi(arg)) < 1)
					prusage(pmProgname);
				nsamples = opts.samples;
			}
		}
	}

	__pmEndOptions(&opts);

	if (opts.errors)
		prusage(pmProgname);

	/*
	** find local host details (no privileged access required)
	*/
	setup_globals(&opts);

	/*
	** check if we are in data recording mode
	*/
	if (rawwriteflag)
	{
		rawwrite(&opts, rawname, &interval, nsamples, midnightflag);
		cleanstop(0);
	}

	/*
	** catch signals for proper close-down
	*/
	signal(SIGHUP,  cleanstop);
	signal(SIGTERM, cleanstop);

	/*
	** switch-on the process-accounting mechanism to register the
	** (remaining) resource-usage by processes which have finished
	*/
	acctreason = acctswon();

	/*
	** determine properties (like speed) of all interfaces
	*/
	initifprop();

	/*
 	** open socket to the IP layer to issue getsockopt() calls later on
	*/
	netatop_ipopen();

	/*
	** start the engine now .....
	*/
	engine();

	cleanstop(0);

	return 0;	/* never reached */
}
开发者ID:ryandoyle,项目名称:pcp,代码行数:101,代码来源:atop.c

示例13: main

int main(int argc,char* argv[])
{
	int opt;
	PsimagLite::String file("");

	while ((opt = getopt(argc, argv, "f:")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		default: /* '?' */
			err("Wrong usage\n");
		}
	}

	if (file == "") err("Wrong usage\n");

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,
	                                                         geometryParams.sites);

	SizeType dof = 2; // spin

	GeometryLibraryType geometry(geometryParams);
	std::cerr<<geometry;
	SizeType npthreads = 1;
	ConcurrencyType concurrency(&argc,&argv,npthreads);
	EngineType engine(geometry.matrix(),
	                  geometryParams.outputFile,
	                  dof,
	                  EngineType::VERBOSE_YES);
	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp);
	HilbertStateType gs(engine,ne);
	RealType sum = 0;
	for (SizeType i=0;i<ne[0];i++) sum += engine.eigenvalue(i);
	std::cerr<<"Energy="<<dof*sum<<"\n";

	SizeType n = geometryParams.sites;
	SizeType norb = (geometryParams.type == GeometryLibraryType::FEAS ||
	                 geometryParams.type == GeometryLibraryType::FEAS1D) ?
	            geometryParams.orbitals : 1;

	for (SizeType orbital1=0; orbital1<norb; orbital1++) {
		for (SizeType orbital2=0; orbital2<norb; orbital2++) {
			for (SizeType site = 0; site<n ; site++) {
				OpNormalFactoryType opNormalFactory(engine);
				OperatorType& myOp1 = opNormalFactory(OperatorType::DESTRUCTION,
				                                      site+orbital1*n,
				                                      SPIN_DOWN);
				OperatorType& myOp2 = opNormalFactory(OperatorType::CREATION,
				                                      site+orbital1*n,
				                                      SPIN_UP);
				OperatorType& myOp3 = opNormalFactory(OperatorType::DESTRUCTION,
				                                      site+orbital1*n,
				                                      SPIN_UP);
				OperatorType& myOp4 = opNormalFactory(OperatorType::CREATION,
				                                      site+orbital1*n,
				                                      SPIN_DOWN);
				HilbertStateType phi1 = gs;
				myOp1.applyTo(phi1);
				myOp2.applyTo(phi1);
				HilbertStateType phi2 = gs;
				myOp3.applyTo(phi2);
				myOp4.applyTo(phi2);
				for (SizeType site2=0; site2<n; site2++) {
					OperatorType& myOp5 = opNormalFactory(OperatorType::DESTRUCTION,
					                                      site2+orbital2*n,
					                                      SPIN_DOWN);
					OperatorType& myOp6 = opNormalFactory(OperatorType::CREATION,
					                                      site2+orbital2*n,
					                                      SPIN_UP);
					OperatorType& myOp7 = opNormalFactory(OperatorType::DESTRUCTION,
					                                      site2+orbital2*n,
					                                      SPIN_UP);
					OperatorType& myOp8 = opNormalFactory(OperatorType::CREATION,
					                                      site2+orbital2*n,
					                                      SPIN_DOWN);
					HilbertStateType phi3 = gs;
					myOp5.applyTo(phi3);
					myOp6.applyTo(phi3);
					HilbertStateType phi4 = gs;
					myOp7.applyTo(phi4);
					myOp8.applyTo(phi4);
					RealType  x13 = scalarProduct(phi3,phi1);
					RealType  x24 = scalarProduct(phi4,phi2);
					std::cout<<(x13+x24)<<" ";
					//cicj(site,site2) += scalarProduct(gs,phi);
				}

				std::cout<<"\n";
			}

			std::cout<<"-------------------------------------------\n";
		}
	}
}
开发者ID:g1257,项目名称:FreeFermions,代码行数:100,代码来源:splusSminus.cpp

示例14: main


//.........这里部分代码省略.........
      Hp.dy=1.0/Hp.ny;
      iDiv=100;
      jDiv=500;
      sprintf(Ha.outPre,"outDir/sod");
      Ha.tend=-1.0;
      Ha.dtoutput=-0.01;
      Ha.nstepmax=1000;
      Ha.noutput=-1;
      break;
    case 2:
      Hp.nx=1000;
      Hp.ny=1000;
      Hp.dx=1.0/Hp.nx;
      Hp.dy=1.0/Hp.ny;
      iDiv=500;
      jDiv=500;
      sprintf(Ha.outPre,"outDir/crn");
      Ha.tend=-1.0;
      Ha.dtoutput=-0.01;
      Ha.nstepmax=1000;
      Ha.noutput=-1;
      break;
    case 3:
      Hp.nx=100;
      Hp.ny=1000*pSMul;
      Hp.dx=0.25/Hp.nx;
      Hp.dy=1.0/Hp.ny;
      iDiv=100;
      jDiv=0.5*Hp.ny;
      sprintf(Ha.outPre,"outDir/wsc");
      Ha.tend=-1.0;
      Ha.dtoutput=-0.01;
      Ha.nstepmax=1000;
      Ha.noutput=-1;
      break;
    case 4:
      Hp.nx=10*pSMul;
      Hp.ny=10*pSMul;
      Hp.dx=1.0/Hp.nx;
      Hp.dy=1.0/Hp.ny;
      iDiv=4;
      jDiv=500;
      sprintf(Ha.outPre,"outDir/scs");
      Ha.tend=-1.0;
      Ha.dtoutput=-0.01;
      Ha.nstepmax=1000;
      Ha.noutput=-1;
      break;
    default:
      Hp.nx=100;
      Hp.ny=100;
      Hp.dx=0.1;
      Hp.dy=0.1;
      iDiv=0;
      jDiv=0;
      sprintf(Ha.outPre,"outDir/out");
      Ha.tend=-1.0;
      Ha.dtoutput=-0.01;
      Ha.nstepmax=100;
      Ha.noutput=-1;
      break;
  }
  Hp.t=0.0;

  Hp.nvar=4;

  mesh=(double*)malloc(Hp.nvar*Hp.nx*Hp.ny*sizeof(double));

  Hp.gamma=1.4;

  Hp.bndL=BND_REFL;
  Hp.bndR=BND_REFL;
  Hp.bndU=BND_REFL;
  Hp.bndD=BND_REFL;

  Ha.smallr=1e-10;
  Ha.smallc=1e-10;
  Ha.niter_riemann=10;
  
  for(j=0;j<Hp.ny;j++){
    for(i=0;i<Hp.nx;i++){
      mesh[i+Hp.nx*(j+Hp.ny*VARRHO)]=0.125;
      mesh[i+Hp.nx*(j+Hp.ny*VARVX )]=0.0;
      mesh[i+Hp.nx*(j+Hp.ny*VARVY )]=0.0;
      mesh[i+Hp.nx*(j+Hp.ny*VARPR )]=0.25;
    }
  }

  for(j=0;j<jDiv;j++){
    for(i=0;i<iDiv;i++){
      mesh[i+Hp.nx*(j+Hp.ny*VARRHO)]=1.0;
      mesh[i+Hp.nx*(j+Hp.ny*VARVX )]=0.0;
      mesh[i+Hp.nx*(j+Hp.ny*VARVY )]=0.0;
      mesh[i+Hp.nx*(j+Hp.ny*VARPR )]=2.5;
    }
  }

  engine(mesh,&Hp,&Ha);
  free(mesh);
}
开发者ID:losalamos,项目名称:CODY,代码行数:101,代码来源:main.c

示例15: main

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

  print_copyright();

  /* GraphChi initialization will read the command line 
     arguments and the configuration file. */
  graphchi_init(argc, argv);

  /* Metrics object for keeping track of performance counters
     and other information. Currently required. */
  metrics m("item-cf");    
  /* Basic arguments for application */
  min_allowed_intersection = get_option_int("min_allowed_intersection", min_allowed_intersection);
  distance_metric          = get_option_int("distance", JACCARD);
  asym_cosine_alpha        = get_option_float("asym_cosine_alpha", 0.5);
  if (distance_metric != JACCARD && distance_metric != AA && distance_metric != RA && distance_metric != ASYM_COSINE)
    logstream(LOG_FATAL)<<"Wrong distance metric. --distance_metric=XX, where XX should be either 0) JACCARD, 1) AA, 2) RA, 3) ASYM_COSINE" << std::endl;  
  parse_command_line_args();

  mytimer.start();
  int nshards          = convert_matrixmarket<EdgeDataType>(training/*, orderByDegreePreprocessor*/);
  if (nshards != 1)
    logstream(LOG_FATAL)<<"This application currently supports only 1 shard" << std::endl;
  K                        = get_option_int("K", K);
  if (K <= 0)
    logstream(LOG_FATAL)<<"Please specify the number of ratings to generate for each user using the --K command" << std::endl;

  assert(M > 0 && N > 0);
  //initialize data structure which saves a subset of the items (pivots) in memory
  adjcontainer = new adjlist_container();
  //array for marking which items are conected to the pivot items via users.
  relevant_items = new bool[N];

  //store node degrees in an array to be used for AA distance metric
  if (distance_metric == AA || distance_metric == RA)
    latent_factors_inmem.resize(M);

  /* Run */
  ItemDistanceProgram program;
  graphchi_engine<VertexDataType, EdgeDataType> engine(training, nshards, true, m); 
  set_engine_flags(engine);
  engine.set_maxwindow(M+N+1);

  //open output files as the number of operating threads
  out_files.resize(number_of_omp_threads());
  for (uint i=0; i< out_files.size(); i++){
    char buf[256];
    sprintf(buf, "%s.out%d", training.c_str(), i);
    out_files[i] = open_file(buf, "w");
  }

  //run the program
  engine.run(program, niters);

  /* Report execution metrics */
  if (!quiet)
    metrics_report(m);
  
  std::cout<<"Total item pairs compared: " << item_pairs_compared << " total written to file: " << sum(written_pairs) << " pairs with zero distance: " << zero_dist << std::endl;
  if (not_enough)
    logstream(LOG_WARNING)<<"Items that did not have enough similar items: " << not_enough << std::endl;
  for (uint i=0; i< out_files.size(); i++){
    fflush(out_files[i]);
    fclose(out_files[i]);
  }

  std::cout<<"Created "  << number_of_omp_threads() << " output files with the format: " << training << ".outXX, where XX is the output thread number" << std::endl; 

  delete[] relevant_items;
  return 0;
}
开发者ID:yangzorror,项目名称:GraduationDesign,代码行数:71,代码来源:itemcf.cpp


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