这篇教程C++ xprintf函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ xprintf函数的具体用法?C++ xprintf怎么用?C++ xprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xprintf函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: branch_drtom//.........这里部分代码省略......... { stat = glp_get_row_stat(mip, k); dk = glp_get_row_dual(mip, k); } else { stat = glp_get_col_stat(mip, k-m); dk = glp_get_col_dual(mip, k-m); } /* if the current basis is dual degenerate, some reduced costs which are close to zero may have wrong sign due to round-off errors, so correct the sign of d[k] */ switch (T->mip->dir) { case GLP_MIN: if (stat == GLP_NL && dk < 0.0 || stat == GLP_NU && dk > 0.0 || stat == GLP_NF) dk = 0.0; break; case GLP_MAX: if (stat == GLP_NL && dk > 0.0 || stat == GLP_NU && dk < 0.0 || stat == GLP_NF) dk = 0.0; break; default: xassert(T != T); } /* now knowing the change of x[k] and its reduced cost d[k] we can compute the corresponding change in the objective function delta Z = new Z - old Z = d[k] * delta x[k]; note that due to Tomlin's modification new Z can be even worse than in the adjacent basis */ delta_z = dk * delta_k;skip: /* new Z is never better than old Z, therefore the change delta Z is always non-negative (in case of minimization) or non-positive (in case of maximization) */ switch (T->mip->dir) { case GLP_MIN: xassert(delta_z >= 0.0); break; case GLP_MAX: xassert(delta_z <= 0.0); break; default: xassert(T != T); } /* save the change in the objective fnction for down- and up-branches, respectively */ if (kase < 0) dz_dn = delta_z; else dz_up = delta_z; } /* thus, in down-branch no integer feasible solution can be better than Z + dz_dn, and in up-branch no integer feasible solution can be better than Z + dz_up, where Z is value of the objective function in the current basis */ /* following the heuristic by Driebeck and Tomlin we choose a column (i.e. structural variable) which provides largest degradation of the objective function in some of branches; besides, we select the branch with smaller degradation to be solved next and keep other branch with larger degradation in the active list hoping to minimize the number of further backtrackings */ if (degrad < fabs(dz_dn) || degrad < fabs(dz_up)) { jj = j; if (fabs(dz_dn) < fabs(dz_up)) { /* select down branch to be solved next */ next = GLP_DN_BRNCH; degrad = fabs(dz_up); } else { /* select up branch to be solved next */ next = GLP_UP_BRNCH; degrad = fabs(dz_dn); } /* save the objective changes for printing */ dd_dn = dz_dn, dd_up = dz_up; /* if down- or up-branch has no feasible solution, we does not need to consider other candidates (in principle, the corresponding branch could be pruned right now) */ if (degrad == DBL_MAX) break; } } /* free working arrays */ xfree(ind); xfree(val); /* something must be chosen */ xassert(1 <= jj && jj <= n);#if 1 /* 02/XI-2009 */ if (degrad < 1e-6 * (1.0 + 0.001 * fabs(mip->obj_val))) { jj = branch_mostf(T, &next); goto done; }#endif if (T->parm->msg_lev >= GLP_MSG_DBG) { xprintf("branch_drtom: column %d chosen to branch on/n", jj); if (fabs(dd_dn) == DBL_MAX) xprintf("branch_drtom: down-branch is infeasible/n"); else xprintf("branch_drtom: down-branch bound is %.9e/n", lpx_get_obj_val(mip) + dd_dn); if (fabs(dd_up) == DBL_MAX) xprintf("branch_drtom: up-branch is infeasible/n"); else xprintf("branch_drtom: up-branch bound is %.9e/n", lpx_get_obj_val(mip) + dd_up); }done: *_next = next; return jj;}
开发者ID:AlessiaWent,项目名称:igraph,代码行数:101,
示例2: bcm6352_enet_write/* -------------------------------------------------------------------------- Name: bcm6352_enet_write Purpose: Sends a data buffer.-------------------------------------------------------------------------- */static int bcm6352_enet_write(cfe_devctx_t *ctx,iocb_buffer_t *buffer){ int copycount; unsigned int srclen; unsigned char *dstptr; unsigned char *srcptr; bcm6352enet_softc *softc = (bcm6352enet_softc *) ctx->dev_softc; volatile DmaChannel *txDma = softc->txDma; /* ============================= ASSERTIONS ============================= */ if( ctx == NULL ) { xprintf( "No context/n" ); return -1; } if( buffer == NULL ) { xprintf( "No dst buffer/n" ); return -1; } if( buffer->buf_length > ENET_MAX_BUF_SIZE ) { xprintf( "src buffer too large./n" ); xprintf( "size is %d/n", buffer->buf_length ); return -1; } if( softc == NULL ) { xprintf( "softc has not been initialized./n" ); return -1; } /* ====================================================================== */ /******** Convert header to Broadcom's special header format. ********/ dstptr = softc->txBufPtr; srcptr = buffer->buf_ptr; srclen = buffer->buf_length; memcpy( dstptr, srcptr, ETH_ALEN * 2 ); dstptr += ETH_ALEN * 2; srcptr += ETH_ALEN * 2; *((uint16_t *)dstptr) = BRCM_TYPE; dstptr += 2; if( srclen < 60 - 6 - 8 ) { *((uint16_t *)dstptr) = (uint16_t)60; } else { *((uint16_t *)dstptr) = (uint16_t)(srclen + 6 + 8); } dstptr += 2; *((uint16_t *)dstptr) = (uint16_t)MANAGEMENT_PORT; dstptr += 2; copycount = srclen - ETH_ALEN * 2; memcpy( dstptr, srcptr, copycount ); if( srclen < 60 ) { dstptr += copycount; memset( dstptr, 0, 60 - srclen ); txDma->length = 66; } else { txDma->length = srclen + 6; } /* Set status of DMA buffer to be transmitted. */ txDma->bufStat = DMA_SOP | DMA_EOP | DMA_APPEND_CRC | DMA_OWN; /* Enable DMA for this channel. */ softc->txDma->cfg |= DMA_ENABLE; /* poll the dma status until done. */ while( (txDma->bufStat & DMA_OWN) == 0 ) ; txDma->bufStat = 0; return 0;}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:85,
示例3: mainvoid main() { int n; xprintf("a/n%d/n%d/n%10d/n%010d/n%u/n%x/n%c/n%s/n%n", 42, -10, 1, 5, 1234, 0xabcdef5, 'c', "Hello", &n); xprintf("%d/n", n);}
开发者ID:regehr,项目名称:solid_code_class,代码行数:6,
示例4: mainint main(void){ int LogOn = 0; int ComOn = 0; int dT; int16_t data[32]; uint32_t x; UINT cnt; InitSystemTick(); InitGPIO(); InitTimer(); STM_EVAL_LEDOn(LED4); InitUART(115200); InitPressureSensor(); InitFlowMeter(); InitAccAndMag(); InitGyro(); STM_EVAL_LEDOn(LED7); // zapnem LED7 - zelena Delta_us(); while(1) { // sample period is time elapsed since previous sampling of sensors sampleSensors(a,m,g); // update timebase for next time dT = Delta_us(); samplePeriod = 0.000001f * dT; // convert gyro deg/s to rad/s imuDegToRadV3(g); // update AHRS MadgwickFullAHRSUpdate(g, a, m, samplePeriod, quaternion); if (LogOn) { sprintf(text, "%5d%6d%6d%6d%7d%7d%7d%5d%5d%5d/r/n", dT, aRawData[0], aRawData[1], aRawData[2], gRawData[0], gRawData[1], gRawData[2], mRawData[0], mRawData[1], mRawData[2]); f_write(&File, text, strlen(text), &cnt); } if(STM_EVAL_PBGetState(BUTTON_USER)) { // zmena rezimu vystupu if (LogOn) { // Stop logdata LogOn = 0; STM_EVAL_LEDOff(LED5); // zapnem LED7 - zelena if (f_close(&File) == 0) xprintf("Stop login data./n/r"); else xprintf("Error write datafile./n/r"); } else { // Start logdata if (newFile() == 0) xprintf("Start login data./n/r"); else xprintf("Error create datafile./n/r"); STM_EVAL_LEDOn(LED5); // zapnem LED7 - zelena LogOn = 1; } } if (ComOn) { data[0] = dT; data[1] = aRawData[0]; data[2] = aRawData[1]; data[3] = aRawData[2]; data[4] = gRawData[0]; data[5] = gRawData[1]; data[6] = gRawData[2]; data[7] = mRawData[0]; data[8] = mRawData[1]; data[9] = mRawData[2]; data[10] = 0x8080; SendDataUART((uint8_t*) data, 22); } if (IsReceiveUART()) { if (ReadByteUART() == 's') { STM_EVAL_LEDOn(LED10); // zapnem LED7 - zelena ComOn = 1; } else { STM_EVAL_LEDOff(LED10); // zapnem LED7 - zelena ComOn = 0; } }/* if (x = GetFlowMeter()) { printf("Flow: %d/n/r", x); }*/ }}
开发者ID:bearxiong99,项目名称:QUAD32,代码行数:96,
|