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


C++ d函数代码示例

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


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

示例1: scan_bulk

void scan_bulk(const class scanner_params &sp,const recursion_control_block &rcb)
{
    assert(sp.sp_version==scanner_params::CURRENT_SP_VERSION);      
    // startup
    if(sp.phase==scanner_params::PHASE_STARTUP){
        assert(sp.info->si_version==scanner_info::CURRENT_SI_VERSION);
	sp.info->name		= "bulk";
	sp.info->author		= "Simson Garfinkel";
	sp.info->description	= "perform bulk data scan";
	sp.info->flags		= scanner_info::SCANNER_DISABLED | scanner_info::SCANNER_WANTS_NGRAMS | scanner_info::SCANNER_NO_ALL;
	sp.info->feature_names.insert("bulk");
	sp.info->feature_names.insert("bulk_tags");
        sp.info->get_config("bulk_block_size",&opt_bulk_block_size,"Block size (in bytes) for bulk data analysis");

        debug = sp.info->config->debug;

	histogram::precalc_entropy_array(opt_bulk_block_size);

        sp.info->get_config("DFRWS2012",&dfrws_challenge,"True if running DFRWS2012 challenge code");
        return; 
    }
    // classify a buffer
    if(sp.phase==scanner_params::PHASE_SCAN){

	feature_recorder *bulk = sp.fs.get_name("bulk");
	feature_recorder *bulk_tags = sp.fs.get_name("bulk_tags");
    

	if(sp.sbuf.pos0.isRecursive()){
	    /* Record the fact that a recursive call was made, which tells us about the data */
	    bulk_tags->write_tag(sp.sbuf,""); // tag that we found recursive data, not sure what kind
	}

	if(sp.sbuf.pagesize < opt_bulk_block_size) return; // can't analyze something that small

	// Loop through the sbuf in opt_bulk_block_size sized chunks
	// for each one, examine the entropy and scan for bitlocker (unfortunately hardcoded)
	// This needs to have a general plug-in architecture
	for(size_t base=0;base+opt_bulk_block_size<=sp.sbuf.pagesize;base+=opt_bulk_block_size){
	    sbuf_t sbuf(sp.sbuf,base,opt_bulk_block_size);
	    bulk_ngram_entropy(sbuf,bulk,bulk_tags);
	    bulk_bitlocker(sbuf,bulk,bulk_tags);
	}
    }
    // shutdown --- combine the results if we are in DFRWS mode
    if(sp.phase==scanner_params::PHASE_SHUTDOWN){
	if(dfrws_challenge){
	    feature_recorder *bulk = sp.fs.get_name("bulk");
	    // First process the bulk_tags and lift_tags
	    bulk_process_feature_file(bulk->outdir + "/bulk_tags.txt"); 
	    bulk_process_feature_file(bulk->outdir + "/lift_tags.txt"); 

	    // Process the remaining feature files
	    dig d(bulk->outdir);
	    for(dig::const_iterator it = d.begin(); it!=d.end(); ++it){
		if(ends_with(*it,_TEXT("_tags.txt"))==false){
		    bulk_process_feature_file(*it);
		}
	    }
	    dfrws2012_bulk_process_dump();
	}
	return;		// no cleanup
    }
}
开发者ID:stumpyuk1,项目名称:bulk_extractor,代码行数:64,代码来源:scan_bulk.cpp

示例2: stream_reset

static int
stream_reset (GMimeStream *stream)
{
	d(g_warning ("Invoked default stream_reset implementation."));
	return 0;
}
开发者ID:tizenorg,项目名称:platform.upstream.gmime,代码行数:6,代码来源:gmime-stream.c

示例3: stream_tell

static gint64
stream_tell (GMimeStream *stream)
{
	d(g_warning ("Invoked default stream_tell implementation."));
	return stream->position;
}
开发者ID:tizenorg,项目名称:platform.upstream.gmime,代码行数:6,代码来源:gmime-stream.c

示例4: d

  Int Interface::innerNormalDirection (Real & infeasible_gradient) {
    Real oldnormc = c->norm();
    Vector d(*env), dcp(*env), dn(*env);
    Real ndn;
    Real alpha, Ared, Pred;
    Real one[2] = {1,0};
    Real zero[2] = {0,0};
    Int iout, naflag;
    Bool dnavail;
    Vector gtmp (*env);
    Vector xtmp (*xc), ctmp (*c), stmp (*env);
    Real normgtmp = 0;

    Aavail = dciFalse;

    Real scalingMatrix[nvar + nconI];
    gtmp.sdmult (*J, 1, one, zero, ctmp); // g = J'*c
    pReal gtmpx = gtmp.get_doublex();
    for (Int i = 0; i < nvar+nconI; i++) {
      Real gi = gtmpx[i], zi = xcx[i], ui = u_bndx[i], li = l_bndx[i];
      if ( (gi < 0) && (ui < dciInf) ) {
        scalingMatrix[i] = 1.0/sqrt(ui - zi);
      } else if ( (gi > 0) && (li > -dciInf) ) {
        scalingMatrix[i] = 1.0/sqrt(zi - li);
      } else {
        scalingMatrix[i] = 1;
      }
    }
    normgtmp = gtmp.norm ();
    Vector gtmp_proj(*env);
    gtmp_proj.scale(gtmp, -1.0);
    projectBounds_xc(gtmp_proj);
    infeasible_gradient = gtmp_proj.norm();
//    DeltaV = normgtmp;

    if (normgtmp < dciTiny) {
      normc = oldnormc;
      iout = 6;
//      std::cout << "iout = 6" << std::endl;
      return iout;
    }
    //Now with the infinity norm
    Real lower[nvar + nconI], upper[nvar + nconI];
    for (Int i = 0; i < nvar+nconI; i++) {
      Real zi = xcx[i], li = l_bndx[i], ui = u_bndx[i];
      lower[i] = Max( -DeltaV,
          (li > -dciInf ? (li - zi) * (1 - epsmu) : -dciInf) );
      upper[i] = Min(  DeltaV,
          (ui <  dciInf ? (ui - zi) * (1 - epsmu) :  dciInf) );
    }
    Vector aux(*env);
    d = gtmp;
    pReal dx = 0;
    gtmpx = gtmp.get_doublex();
    dx = d.get_doublex();
    for (Int i = 0; i < nvar + nconI; i++) {
      gtmpx[i] /= scalingMatrix[i];
      dx[i] = -dx[i]/pow(scalingMatrix[i], 2);
    }

    aux.sdmult(*J, 0, one, zero, d);
    alpha = Min(gtmp.dot(gtmp)/aux.dot(aux), DeltaV/gtmp.norm());
    dcp.scale (d, alpha);
    pReal dcpx = dcp.get_doublex();

//    alpha = -d.dot(gtmp)/aux.dot(aux);
//    alpha = Min(alpha, DeltaV/d.norm());
    alpha = 1.0;
    for (int i = 0; i < nvar + nconI; i++) {
      Real di = dcpx[i], ui = upper[i], li = lower[i];
      if (di > dciEps) {
        alpha = Min(alpha, ui/(di));
      } else if (di < -dciEps) {
        alpha = Min(alpha, li/(di));
      } else
        dcpx[i] = 0;
    }
    Real theta = 0.99995;
    if (alpha < 1) {
      alpha = Max(theta, 1 - dcp.norm())*alpha;
      dcp.scale(alpha);
    }
/*     for (Int i = 0; i < nvar + nconI; i++)
 *       dcpx[i] *= scalingMatrix[i];
 */
    dnavail = dciFalse;
    ndn = 0;
    Ared = 0;
    Pred = 1;
//    DeltaV = DeltaV/kappa2;
    iout = 0;

    // For the inequalities
    pReal dnx = 0;

    dnavail = dciFalse;
    if (!dnavail) {
      naflag = naStep (*c, dn);

      dnavail = dciTrue;
//.........这里部分代码省略.........
开发者ID:abelsiqueira,项目名称:dcicpp,代码行数:101,代码来源:dciinnernormal.cpp

示例5: stream_write

static ssize_t
stream_write (GMimeStream *stream, const char *buf, size_t len)
{
	d(g_warning ("Invoked default stream_write implementation."));
	return 0;
}
开发者ID:tizenorg,项目名称:platform.upstream.gmime,代码行数:6,代码来源:gmime-stream.c

示例6: solve_quadprog

inline double solve_quadprog(MatrixXd & G,  VectorXd & g0,
                             const MatrixXd & CE, const VectorXd & ce0,
                             const MatrixXd & CI, const VectorXd & ci0,
                             VectorXd& x)
{
    int i, j, k, l; /* indices */
    int ip, me, mi;
    int n=g0.size();
    int p=ce0.size();
    int m=ci0.size();
    MatrixXd R(G.rows(),G.cols()), J(G.rows(),G.cols());

    LLT<MatrixXd,Lower> chol(G.cols());

    VectorXd s(m+p), z(n), r(m + p), d(n),  np(n), u(m + p);
    VectorXd x_old(n), u_old(m + p);
    double f_value, psi, c1, c2, sum, ss, R_norm;
    const double inf = std::numeric_limits<double>::infinity();
    double t, t1, t2; /* t is the step length, which is the minimum of the partial step length t1
    * and the full step length t2 */
    VectorXi A(m + p), A_old(m + p), iai(m + p);
    int q;
    int iq, iter = 0;
    bool iaexcl[m + p];

    me = p; /* number of equality constraints */
    mi = m; /* number of inequality constraints */
    q = 0;  /* size of the active set A (containing the indices of the active constraints) */

    /*
     * Preprocessing phase
     */

    /* compute the trace of the original matrix G */
    c1 = G.trace();

    /* decompose the matrix G in the form LL^T */
    chol.compute(G);

    /* initialize the matrix R */
    d.setZero();
    R.setZero();
    R_norm = 1.0; /* this variable will hold the norm of the matrix R */

    /* compute the inverse of the factorized matrix G^-1, this is the initial value for H */
    // J = L^-T
    J.setIdentity();
    J = chol.matrixU().solve(J);
    c2 = J.trace();
#ifdef TRACE_SOLVER
    print_matrix("J", J, n);
#endif

    /* c1 * c2 is an estimate for cond(G) */

    /*
    * Find the unconstrained minimizer of the quadratic form 0.5 * x G x + g0 x
    * this is a feasible point in the dual space
     * x = G^-1 * g0
    */
    x = chol.solve(g0);
    x = -x;
    /* and compute the current solution value */
    f_value = 0.5 * g0.dot(x);
#ifdef TRACE_SOLVER
    std::cerr << "Unconstrained solution: " << f_value << std::endl;
    print_vector("x", x, n);
#endif

    /* Add equality constraints to the working set A */
    iq = 0;
    for (i = 0; i < me; i++)
    {
        np = CE.col(i);
        compute_d(d, J, np);
        update_z(z, J, d,  iq);
        update_r(R, r, d,  iq);
#ifdef TRACE_SOLVER
        print_matrix("R", R, iq);
        print_vector("z", z, n);
        print_vector("r", r, iq);
        print_vector("d", d, n);
#endif

        /* compute full step length t2: i.e., the minimum step in primal space s.t. the contraint
          becomes feasible */
        t2 = 0.0;
        if (std::abs(z.dot(z)) > std::numeric_limits<double>::epsilon()) // i.e. z != 0
            t2 = (-np.dot(x) - ce0(i)) / z.dot(np);

        x += t2 * z;

        /* set u = u+ */
        u(iq) = t2;
        u.head(iq) -= t2 * r.head(iq);

        /* compute the new solution value */
        f_value += 0.5 * (t2 * t2) * z.dot(np);
        A(i) = -i - 1;

//.........这里部分代码省略.........
开发者ID:EnricoMingo,项目名称:testQPsolvers,代码行数:101,代码来源:eiquadprog.hpp

示例7: hongocompleto

void hongocompleto()
{
int i=0;
do{

//for(i=6;i<9;i++)
//{
setbkcolor(WHITE);
construccion();
////C
setcolor (7);
settextstyle (0,0,5);
outtextxy (30,50,"C");
////A
setcolor (7);
settextstyle (0,0,5);
outtextxy (70,55,"A");
/////R
setcolor (7);
settextstyle (0,0,5);
outtextxy (110,50,"R");

/////G
setcolor (7);
settextstyle (0,0,5);
outtextxy (150,55,"G");
/////A
setcolor (7);
settextstyle (0,0,5);
outtextxy (190,50,"A");
/////N
setcolor (7);
settextstyle (0,0,5);
outtextxy (230,55,"N");
/////D
setcolor (7);
settextstyle (0,0,5);
outtextxy (270,50,"D");
/////O
setcolor (7);
settextstyle (0,0,5);
outtextxy (310,55,"O");
c();
//a1();
//r();
//g();
//a2();
//n();
//d();
//o();
//c();
delay(200);
cabeza();
a1();
delay(200);
ojo();
r();

delay(200);
mancha1();
g();
delay(200);

mancha2();
a2();
delay(200);

mancha3();
n();
delay(200);

mancha4();
d();
delay(200);

mancha5();
o();
delay(200);
//getch();
i=i++;

//kbhit();
}while (i<2);
//}while (!kbhit());
}
开发者ID:ManuelAlanis,项目名称:BatallaNaval-C,代码行数:85,代码来源:1.CPP

示例8: sc_main

int sc_main(int, char**) {
    sc_signal<bool> Clk, Rst, Tx_Active, CCA_Active, MEM_Read;
    sc_signal< sc_uint<8> > RFST_in, MUX, Instruction;
    sc_signal< sc_uint<16> >Random_in;
    sc_signal<bool> Txcaln, Txon, Txoncca, ackset, Txoff, flush_tx, Rxon, Rxoff, flush_rx;
    sc_signal< sc_uint<32> > i;
    sc_signal< sc_uint<4> > W;
    sc_signal< sc_uint<3> > CSPSelmux_1;
    sc_signal< sc_uint<2> > CSPSelmux_2;

    /*sc_signal<bool> Encspx, Encspy, Incy, Decy, Encspz, Decz, Encspt, Dect, Encspctrl, Enpc, Enir, MEM_Read, Enmactimer, CSPC_out;
    sc_signal< sc_uint<3> > S, CSPSelmux_1;
    sc_signal< sc_uint<2> > CSPSelmux_2;
    sc_signal< sc_uint<8> > CSPX_out, CSPY_out, CSPZ_out, CSPT_out, CSPCTRL_out, CSPPC_out, CSPIR_out, RFST_out, CSPMux_1_out,
    	Memory_out, CSPR_out, OFECou;
    */
    CSPTOP DUT("CSPTOP");
    DUT.Clk(Clk);
    DUT.Rst(Rst);
    DUT.Tx_Active(Tx_Active);
    DUT.CCA_Active(CCA_Active);
    DUT.RFST_in(RFST_in);
    DUT.Random_in(Random_in);

    DUT.CSPIR_out(Instruction);
    DUT.W(W);
    DUT.MUX(MUX);
    DUT.i(i);
    DUT.Txcaln(Txcaln);
    DUT.Txon(Txon);
    DUT.Txoncca(Txoncca);
    DUT.ackset(ackset);
    DUT.Txoff(Txoff);
    DUT.flush_tx(flush_tx);
    DUT.Rxon(Rxon);
    DUT.Rxoff(Rxoff);
    DUT.flush_rx(flush_rx);

    DUT.CSPSelmux_2(CSPSelmux_2);
    DUT.CSPSelmux_1(CSPSelmux_1);
    DUT.MEM_Read(MEM_Read);
    /*
    	Control.Clk(Clk);
    	Control.Rst(Rst);
    	Control.OFECou(OFECou);
    	Control.Instruction(CSPIR_out);
    	Control.MUX(MUX);
    	Control.C_out(CSPC_out);

    	Control.i(i);
    	Control.Encspx(Encspx);
    	Control.Encspy(Encspy);
    	Control.Incy(Incy);
    	Control.Decy(Decy);
    	Control.Encspz(Encspz);
    	Control.Decz(Decz);
    	Control.Encspt(Encspt);
    	Control.Dect(Dect);
    	Control.Encspctrl(Encspctrl);
    	Control.Enpc(Enpc);
    	Control.S(S);
    	Control.Enir(Enir);
    	Control.Selmux_1(CSPSelmux_1);
    	Control.Selmux_2(CSPSelmux_2);
    	Control.MEM_Read(MEM_Read);
    	Control.Enmactimer(Enmactimer);
    	Control.Txcaln(Txcaln);
    	Control.Txon(Txon);
    	Control.Txoncca(Txoncca);
    	Control.ackset(ackset);
    	Control.Txoff(Txoff);
    	Control.flush_tx(flush_tx);
    	Control.Rxon(Rxon);
    	Control.Rxoff(Rxoff);
    	Control.flush_rx(flush_rx);
    */

    driver d("driver");
    d.Clk(Clk);
    d.Rst(Rst);
    d.Tx_Active(Tx_Active);
    d.CCA_Active(CCA_Active);
    d.RFST_in(RFST_in);
    d.Random_in(Random_in);
    //d.CSPIR_out(CSPIR_out);
    //d.OFECou(OFECou);
    //d.MUX(MUX);
    //d.C_out(CSPC_out);

    // trace file creation
    sc_trace_file *tf = sc_create_vcd_trace_file("CSPTOP");
    sc_trace(tf,DUT.Clk, "Clk");
    sc_trace(tf,DUT.Rst, "Rst");
    sc_trace(tf,DUT.Tx_Active, "Tx_Active");
    sc_trace(tf,DUT.CCA_Active, "CCA_Active");
    sc_trace(tf,DUT.RFST_in, "RFST_in");
    sc_trace(tf,DUT.Random_in, "Random_in");

    sc_trace(tf,DUT.Txcaln, "Txcaln");
    sc_trace(tf,DUT.Txon, "Txon");
//.........这里部分代码省略.........
开发者ID:joeeeeoj,项目名称:SystemC,代码行数:101,代码来源:main.cpp

示例9: a

		GLvoid CRenderManager::handlePickedObjects()
		{
			// if we are ower the menu we do not have to proccess things under the cursor
			if (CV_GAME_MANAGER->getGUIManager()->getPlayGUI()->is_mouse_over_gui())
			{
				return;
			}

			// if we are not selling or buying we don't have to process blocks (just objects TODO)
			ACTION_EVENT *ae = CV_GAME_MANAGER->getGUIManager()->getLastActionEvent();
			
			// get the block we have our cousor on
			CBlock *pickedBlock = CV_GAME_MANAGER->getPickingManager()->getLastPickedBlock();

			if (pickedBlock)
			{
				GLint type = pickedBlock->getType();

				/*if (!pickedBlock->isSellable())
				{
					return;
				}*/

				sBoundingBox *bbox = pickedBlock->getBoundingBox();

				vector3f a(bbox->A);
				vector3f b(bbox->B);
				vector3f c(bbox->C);
				vector3f d(bbox->D);
				vector3f e(bbox->E);
				vector3f f(bbox->F);
				vector3f g(bbox->G);
				vector3f h(bbox->H);

				a[1]=b[1]=c[1]=d[1]=CV_BLOCK_HEIGHT+CV_BLOCK_HEIGHT/4.0f+CV_BLOCK_HEIGHT/32.0f;
				e[1]=f[1]=g[1]=h[1]=CV_BLOCK_HEIGHT/4.0f+CV_BLOCK_HEIGHT/32.0f;

				glLineWidth(4.0f);

				if (pickedBlock->isLow())
				{
					if (!(ae->message_group==AEMG_BUILD_ROOMS || ae->message_group==AEMG_BUILD_DOORS || ae->message_group==AEMG_BUILD_TRAPS))
					{
						return;
					}

					// draw the selection box					

					if (pickedBlock->isSellable(CV_CURRENT_PLAYER_ID) && ae->message == AEM_SELL)
					{
						glColor3f(0.0f,1.0f,0.0f);
					}
					else if (pickedBlock->isBuildable(CV_CURRENT_PLAYER_ID) && ae->message != AEM_SELL)
					{
						glColor3f(0.0f,1.0f,0.0f);
					}
					else
					{
						glColor3f(1.0f,0.0f,0.0f);
					}
					
					glBegin(GL_LINES);
					{
						/*glVertex3fv(&a[0]); glVertex3fv(&b[0]);
						glVertex3fv(&b[0]); glVertex3fv(&c[0]);
						glVertex3fv(&c[0]); glVertex3fv(&d[0]);
						glVertex3fv(&d[0]); glVertex3fv(&a[0]);*/

						glVertex3fv(&e[0]); glVertex3fv(&f[0]);
						glVertex3fv(&f[0]); glVertex3fv(&g[0]);
						glVertex3fv(&g[0]); glVertex3fv(&h[0]);
						glVertex3fv(&h[0]); glVertex3fv(&e[0]);

						/*glVertex3fv(&a[0]); glVertex3fv(&e[0]);
						glVertex3fv(&b[0]); glVertex3fv(&f[0]);
						glVertex3fv(&c[0]); glVertex3fv(&g[0]);
						glVertex3fv(&d[0]); glVertex3fv(&h[0]);*/
					}
					glEnd();
				}
				else
				{		
					if (!(ae->message_group==AEMG_BUILD_ROOMS || ae->message_group==AEMG_BUILD_DOORS || ae->message_group==AEMG_BUILD_TRAPS))
						glColor3f(type==CV_BLOCK_TYPE_ROCK_ID?1.0f:0.0f,type==CV_BLOCK_TYPE_ROCK_ID?0.0f:1.0f,0.0f);
					else
						glColor3f(1.0f,0.0f,0.0f);
			
					glBegin(GL_LINES);
					{
						glVertex3fv(&a[0]); glVertex3fv(&b[0]);
						glVertex3fv(&b[0]); glVertex3fv(&c[0]);
						glVertex3fv(&c[0]); glVertex3fv(&d[0]);
						glVertex3fv(&d[0]); glVertex3fv(&a[0]);

						glVertex3fv(&e[0]); glVertex3fv(&f[0]);
						glVertex3fv(&f[0]); glVertex3fv(&g[0]);
						glVertex3fv(&g[0]); glVertex3fv(&h[0]);
						glVertex3fv(&h[0]); glVertex3fv(&e[0]);

						glVertex3fv(&a[0]); glVertex3fv(&e[0]);
//.........这里部分代码省略.........
开发者ID:Captnoord,项目名称:NBK,代码行数:101,代码来源:RenderManager.cpp

示例10: main

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

  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
  Teuchos::RCP<const Teuchos::Comm<int> > comm
    = Teuchos::DefaultComm<int>::getComm();

  // This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
  int iprint = argc - 1;
  Teuchos::RCP<std::ostream> outStream;
  Teuchos::oblackholestream bhs; // outputs nothing
  if (iprint > 0 && Teuchos::rank<int>(*comm)==0)
    outStream = Teuchos::rcp(&std::cout, false);
  else
    outStream = Teuchos::rcp(&bhs, false);

  int errorFlag  = 0;

  try {
    /**********************************************************************************************/
    /************************* CONSTRUCT ROL ALGORITHM ********************************************/
    /**********************************************************************************************/
    // Get ROL parameterlist
    std::string filename = "input.xml";
    Teuchos::RCP<Teuchos::ParameterList> parlist = Teuchos::rcp( new Teuchos::ParameterList() );
    Teuchos::updateParametersFromXmlFile( filename, parlist.ptr() );
    // Build ROL algorithm
    parlist->sublist("Status Test").set("Gradient Tolerance",1.e-8);
    parlist->sublist("Status Test").set("Step Tolerance",1.e-14);
    parlist->sublist("Status Test").set("Iteration Limit",100);
    /**********************************************************************************************/
    /************************* CONSTRUCT VECTORS **************************************************/
    /**********************************************************************************************/
    // Build control vectors
    int nx = 256;
    Teuchos::RCP<std::vector<RealT> > x_rcp  = Teuchos::rcp( new std::vector<RealT>(nx+2,0.0) );
    ROL::StdVector<RealT> x(x_rcp);
    Teuchos::RCP<std::vector<RealT> > d_rcp  = Teuchos::rcp( new std::vector<RealT>(nx+2,0.0) );
    ROL::StdVector<RealT> d(d_rcp);
    for ( int i = 0; i < nx+2; i++ ) {
      (*x_rcp)[i] = random<RealT>(comm);
      (*d_rcp)[i] = random<RealT>(comm);
    }
    // Build state and adjoint vectors
    Teuchos::RCP<std::vector<RealT> > u_rcp  = Teuchos::rcp( new std::vector<RealT>(nx,1.0) );
    ROL::StdVector<RealT> u(u_rcp);
    Teuchos::RCP<std::vector<RealT> > p_rcp  = Teuchos::rcp( new std::vector<RealT>(nx,0.0) );
    ROL::StdVector<RealT> p(p_rcp);
    Teuchos::RCP<ROL::Vector<RealT> > up = Teuchos::rcp(&u,false);
    Teuchos::RCP<ROL::Vector<RealT> > pp = Teuchos::rcp(&p,false);
    /**********************************************************************************************/
    /************************* CONSTRUCT SOL COMPONENTS *******************************************/
    /**********************************************************************************************/
    // Build samplers
//    int dim = 4;
//    int nSamp = 100;
//    std::vector<RealT> tmp(2,0.0); tmp[0] = -1.0; tmp[1] = 1.0;
//    std::vector<std::vector<RealT> > bounds(dim,tmp);
//    Teuchos::RCP<ROL::BatchManager<RealT> > bman
//      = Teuchos::rcp(new ROL::StdTeuchosBatchManager<RealT,int>(comm));
//    Teuchos::RCP<ROL::SampleGenerator<RealT> > sampler
//      = Teuchos::rcp(new ROL::MonteCarloGenerator<RealT>(nSamp,bounds,bman,false,false,100));
    ROL::QuadratureInfo info;
    info.dim = 4;
    info.maxLevel = 7;
    info.rule1D.clear(); info.rule1D.resize(info.dim,ROL::QUAD_CLENSHAWCURTIS);    
    info.growth1D.clear(); info.growth1D.resize(info.dim,ROL::GROWTH_DEFAULT);
    info.normalized = true;
    info.adaptive = false;
    Teuchos::RCP<ROL::BatchManager<RealT> > bman
      = Teuchos::rcp(new ROL::StdTeuchosBatchManager<RealT,int>(comm));
    Teuchos::RCP<ROL::SampleGenerator<RealT> > sampler
      = Teuchos::rcp(new ROL::SparseGridGenerator<RealT>(bman,info));
    // Print samples
    int width = 21;
    std::stringstream name;
    name << "samples_" << sampler->batchID() << ".txt";
    std::ofstream file(name.str().c_str());
    if (file.is_open()) {
      file << std::scientific << std::setprecision(12);
      for (int i = 0; i < sampler->numMySamples(); ++i) {
        std::vector<RealT> pt = sampler->getMyPoint(i);
        RealT wt = sampler->getMyWeight(i);
        for (int j = 0; j < static_cast<int>(pt.size()); ++j) {
          file << std::setw(width) << std::left << pt[j];
        }
        file << std::setw(width) << std::left << wt << std::endl;
      }
      file.close();
    }
    else {
      TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
        ">>> (adapters/trikota/sol/test/test_01): Unable to open file!");
    }

    /**********************************************************************************************/
    /************************* CONSTRUCT OBJECTIVE FUNCTION ***************************************/
    /**********************************************************************************************/
    // Build risk-averse objective function
    RealT alpha = 1.e-3;
    Teuchos::RCP<ROL::ParametrizedObjective_SimOpt<RealT> > pobjSimOpt
//.........这里部分代码省略.........
开发者ID:cihanuq,项目名称:Trilinos,代码行数:101,代码来源:test_01.cpp

示例11: updateFile

// Update a file or directory.
bool updateFile(const QString &sourceFileName, const QStringList &nameFilters,
                const QString &targetDirectory, unsigned flags, JsonOutput *json, QString *errorMessage)
{
    const QFileInfo sourceFileInfo(sourceFileName);
    const QString targetFileName = targetDirectory + QLatin1Char('/') + sourceFileInfo.fileName();
    if (optVerboseLevel > 1)
        std::wcout << "Checking " << sourceFileName << ", " << targetFileName<< '\n';

    if (!sourceFileInfo.exists()) {
        *errorMessage = QString::fromLatin1("%1 does not exist.").arg(QDir::toNativeSeparators(sourceFileName));
        return false;
    }

    if (sourceFileInfo.isSymLink()) {
        *errorMessage = QString::fromLatin1("Symbolic links are not supported (%1).")
                        .arg(QDir::toNativeSeparators(sourceFileName));
        return false;
    }

    const QFileInfo targetFileInfo(targetFileName);

    if (sourceFileInfo.isDir()) {
        if (targetFileInfo.exists()) {
            if (!targetFileInfo.isDir()) {
                *errorMessage = QString::fromLatin1("%1 already exists and is not a directory.")
                                .arg(QDir::toNativeSeparators(targetFileName));
                return false;
            } // Not a directory.
        } else { // exists.
            QDir d(targetDirectory);
            if (optVerboseLevel)
                std::wcout << "Creating " << QDir::toNativeSeparators(targetFileName) << ".\n";
            if (!(flags & SkipUpdateFile) && !d.mkdir(sourceFileInfo.fileName())) {
                *errorMessage = QString::fromLatin1("Cannot create directory %1 under %2.")
                                .arg(sourceFileInfo.fileName(), QDir::toNativeSeparators(targetDirectory));
                return false;
            }
        }
        // Recurse into directory
        QDir dir(sourceFileName);
        const QStringList allEntries = dir.entryList(nameFilters, QDir::Files) + dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
        foreach (const QString &entry, allEntries)
            if (!updateFile(sourceFileName + QLatin1Char('/') + entry, nameFilters, targetFileName, flags, json, errorMessage))
                return false;
        return true;
    } // Source is directory.

    if (targetFileInfo.exists()) {
        if (!(flags & ForceUpdateFile)
            && targetFileInfo.lastModified() >= sourceFileInfo.lastModified()) {
            if (optVerboseLevel)
                std::wcout << sourceFileInfo.fileName() << " is up to date.\n";
            if (json)
                json->addFile(sourceFileName, targetDirectory);
            return true;
        }
        QFile targetFile(targetFileName);
        if (!(flags & SkipUpdateFile) && !targetFile.remove()) {
            *errorMessage = QString::fromLatin1("Cannot remove existing file %1: %2")
                            .arg(QDir::toNativeSeparators(targetFileName), targetFile.errorString());
            return false;
        }
    } // target exists
    QFile file(sourceFileName);
    if (optVerboseLevel)
        std::wcout << "Updating " << sourceFileInfo.fileName() << ".\n";
    if (!(flags & SkipUpdateFile) && !file.copy(targetFileName)) {
        *errorMessage = QString::fromLatin1("Cannot copy %1 to %2: %3")
                .arg(QDir::toNativeSeparators(sourceFileName),
                     QDir::toNativeSeparators(targetFileName),
                     file.errorString());
        return false;
    }
    if (json)
        json->addFile(sourceFileName, targetDirectory);
    return true;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:78,代码来源:utils.cpp

示例12: main

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QDialog d(0);
	QVBoxLayout *gl = new QVBoxLayout();

	QFormLayout *lay = new QFormLayout();
	lay->setWidget(0, QFormLayout::LabelRole, new QLabel(QString::fromLocal8Bit("Имя: "), &d));
	lay->setWidget(0, QFormLayout::FieldRole, new QLineEdit(&d));

	lay->setWidget(1, QFormLayout::LabelRole, new QLabel(QString::fromLocal8Bit("Фамилия: "), &d));
	lay->setWidget(1, QFormLayout::FieldRole, new QLineEdit(&d));

	lay->setWidget(2, QFormLayout::LabelRole, new QLabel(QString::fromLocal8Bit("Отчество: "), &d));
	lay->setWidget(2, QFormLayout::FieldRole, new QLineEdit(&d));
	gl->addLayout(lay);

	QFrame *line = new QFrame(&d);
	line->setFrameShape(QFrame::HLine);
	line->setFrameShadow(QFrame::Sunken);
	gl->addWidget(line);

	lay = new QFormLayout();
	QComboBox *cbox = new QComboBox(&d);
	cbox->insertItem(0, QString::fromLocal8Bit("женский"));
	cbox->insertItem(1, QString::fromLocal8Bit("мужской"));
	lay->setWidget(0, QFormLayout::LabelRole, new QLabel(QString::fromLocal8Bit("Пол: "), &d));
	lay->setWidget(0, QFormLayout::FieldRole, cbox);

	lay->setWidget(1, QFormLayout::LabelRole, new QLabel(QString::fromLocal8Bit("Дата рождения: "), &d));
	lay->setWidget(1, QFormLayout::FieldRole, new QDateEdit(&d));
	gl->addLayout(lay);

	line = new QFrame(&d);
	line->setFrameShape(QFrame::HLine);
	line->setFrameShadow(QFrame::Sunken);
	gl->addWidget(line);

	lay = new QFormLayout();
	lay->setWidget(0, QFormLayout::LabelRole, new QLabel(QString::fromLocal8Bit("Адрес: "), &d));
	lay->setWidget(0, QFormLayout::FieldRole, new QLineEdit(&d));

	lay->setWidget(1, QFormLayout::LabelRole, new QLabel(QString::fromLocal8Bit("Телефон: "), &d));
	lay->setWidget(1, QFormLayout::FieldRole, new QLineEdit(&d));
	gl->addLayout(lay);

	QHBoxLayout *lay2 = new QHBoxLayout();
	QPushButton *ok = new QPushButton("OK", &d);
	ok->setDefault(true);
	ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	lay2->addWidget(ok);
	QPushButton *cancel = new QPushButton(QString::fromLocal8Bit("Отмена"), &d);
	cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	lay2->addWidget(cancel);
	gl->addItem(lay2);

	d.setLayout(gl);
	d.setWindowTitle("Address book");
	d.show();
	return app.exec();
}
开发者ID:bondarevts,项目名称:amse-qt,代码行数:61,代码来源:main.cpp

示例13: dp

void dp(std::vector<std::string> ref, std::vector<std::string> hyp){
	int rcount = (int)ref.size();	//正解文書の単語数
	int hcount = (int)hyp.size();	//コンフュージョンセットの数
	
	std::vector<std::vector<bool> > d(rcount+1, std::vector<bool>(hcount+1));	//一致しているか
	std::vector<std::vector<int> > g(rcount+1, std::vector<int>(hcount+1));		//距離計算
	std::vector<std::vector<int> > r(rcount+1, std::vector<int>(hcount+1));		//置換,削除,挿入

	//dの算出(0:一致,1:不一致)
	for(int i = 1; i <= rcount; i++){
		for(int j = 1; j <= hcount; j++){
			d[i][j] = (ref[i-1] != hyp[j-1]);
		}
	}

	//g,rの端に値を代入
	g[0][0] = 0;
	r[0][0] = 0;

	for(int i = 1; i <= rcount; i++){
		g[i][0] = g[i-1][0] + 1;
		r[i][0] = 1;
	}

	for(int j = 1; j <= hcount; j++){
		g[0][j] = g[0][j-1] + 1;
		r[0][j] = 2;
	}
	
	//g,rの中の計算
	for(int i = 1; i <= rcount; i++){
		for(int j = 1; j <= hcount; j++){
			int l = g[i-1][j] + 1;
			int b = g[i][j-1] + 1;
			int lb = g[i-1][j-1] + d[i][j];
			if(l <= b){
				if(l <= lb){
					g[i][j] = l;
					r[i][j] = 1;
				}
				else{
					g[i][j] = lb;
					r[i][j] = 3;
				}
			}
			else{
				if(b <= lb){
					g[i][j] = b;
					r[i][j] = 2;
				}
				else{
					g[i][j] = lb;
					r[i][j] = 3;
				}
			}
		}
	}
	
	int i = rcount;
	int j = hcount;
	
	for(;;){
		if(r[i][j] == 1){
			del++;
			i--;
		}
		else if(r[i][j] == 2){
			ins++;
			j--;
		}
		else if(r[i][j] == 3){
			if(d[i][j] == 1){
				sub++;
			}
			else{
				cor++;
			}
			i--;
			j--;
		}
		else if(i == 0 && j == 0){
			break;
		}
	}
}
开发者ID:fussa2323,项目名称:two-step_csjnrd,代码行数:85,代码来源:main.cpp

示例14: servername

static QString servername(QString fn) {
  QDir d(QDir::current());
  fn = d.absoluteFilePath(fn);
  fn = QDir::cleanPath(fn);
  return QString("eln-%1").arg(qHash(fn));
}
开发者ID:wagenadl,项目名称:eln,代码行数:6,代码来源:AlreadyOpen.cpp

示例15: MST_linkage_core

void MST_linkage_core(const t_index N, const t_float * const D,
                             cluster_result & Z2) {
/*
    N: integer, number of data points
    D: condensed distance matrix N*(N-1)/2
    Z2: output data structure

    The basis of this algorithm is an algorithm by Rohlf:

    F. James Rohlf, Hierarchical clustering using the minimum spanning tree,
    The Computer Journal, vol. 16, 1973, p. 93–95.
*/
  t_index i;
  t_index idx2;
  doubly_linked_list active_nodes(N);
  auto_array_ptr<t_float> d(N);

  t_index prev_node;
  t_float min;

  // first iteration
  idx2 = 1;
  min = std::numeric_limits<t_float>::infinity();
  for (i=1; i<N; ++i) {
    d[i] = D[i-1];
#if HAVE_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
    if (d[i] < min) {
      min = d[i];
      idx2 = i;
    }
    else if (fc_isnan(d[i]))
      throw (nan_error());
#if HAVE_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
  }
  Z2.append(0, idx2, min);

  for (t_index j=1; j<N-1; ++j) {
    prev_node = idx2;
    active_nodes.remove(prev_node);

    idx2 = active_nodes.succ[0];
    min = d[idx2];
    for (i=idx2; i<prev_node; i=active_nodes.succ[i]) {
      t_float tmp = D_(i, prev_node);
#if HAVE_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
      if (tmp < d[i])
        d[i] = tmp;
      else if (fc_isnan(tmp))
        throw (nan_error());
#if HAVE_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
      if (d[i] < min) {
        min = d[i];
        idx2 = i;
      }
    }
    for (; i<N; i=active_nodes.succ[i]) {
      t_float tmp = D_(prev_node, i);
#if HAVE_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
      if (d[i] > tmp)
        d[i] = tmp;
      else if (fc_isnan(tmp))
        throw (nan_error());
#if HAVE_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
      if (d[i] < min) {
        min = d[i];
        idx2 = i;
      }
    }
    Z2.append(prev_node, idx2, min);
  }
}
开发者ID:23119841,项目名称:CppMT,代码行数:86,代码来源:fastcluster.cpp


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