本文整理汇总了C++中BF函数的典型用法代码示例。如果您正苦于以下问题:C++ BF函数的具体用法?C++ BF怎么用?C++ BF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNode
node *insertNode(node *root, int cont){
if(root==NULL){
return createNode(cont);
}
else
if(cont>root->data) {
root->right=insertNode(root->right,cont);
if(BF(root)==-2){
if(cont>root->right->data)
root=RR(root);
else
root=RL(root);
}
}
else
if(cont<root->data) {
root->left=insertNode(root->left,cont);
if(BF(root)==2){
if(cont < root->left->data)
root=LL(root);
else
root=LR(root);
}
}
/*else{
if(cont==root->data) printf("the node %d already exists in the tree",cont);
return root;
}*/
root->ht=height(root);
return(root);
}
示例2: evaluateFields
void DOFInterpolation<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
//Intrepid version:
// for (int i=0; i < val_qp.size() ; i++) val_qp[i] = 0.0;
// Intrepid::FunctionSpaceTools:: evaluate<ScalarT>(val_qp, val_node, BF);
for (int cell=0; cell < workset.numCells; ++cell) {
for (int qp=0; qp < numQPs; ++qp) {
if (2==numRank) {
typename PHAL::Ref<ScalarT>::type vqp = val_qp(cell,qp) = 0;
for (int node=0; node < numNodes; ++node) {
vqp += val_node(cell, node) * BF(cell, node, qp);
}
} else {
for (int level=0; level < numLevels; ++level) {
typename PHAL::Ref<ScalarT>::type vqp = val_qp(cell,qp,level);
vqp = 0;
for (int node=0; node < numNodes; ++node) {
vqp += val_node(cell, node, level) * BF(cell, node, qp);
}
}
}
}
}
}
示例3: insertion
/* Insert sessid and socket pair in AVL Tree */
AVLTree_Node* insertion(AVLTree_Node *T,uint16_t x, struct node *head)
{
if(T==NULL)
{
T=(AVLTree_Node*)malloc(sizeof(AVLTree_Node));
T->data=x;
T->head = head;
T->left=NULL;
T->right=NULL;
}
else
if(x > T->data) // insert in right subtree
{
T->right=insertion(T->right,x,head);
if(BF(T)==-2)
if(x>T->right->data)
T=RR(T);
else
T=RL(T);
}
else
if(x<T->data)
{
T->left=insertion(T->left,x,head);
if(BF(T)==2)
if(x < T->left->data)
T=LL(T);
else
T=LR(T);
}
T->ht=height(T);
//root=T;
return(T);
}
示例4: stmp3xxx_mmc_bc
/* Send the BC command to the device */
static void stmp3xxx_mmc_bc(struct stmp3xxx_mmc_host *host)
{
struct mmc_command *cmd = host->cmd;
struct stmp3xxx_dma_descriptor *dma_desc = &host->dma_desc;
dma_desc->command->cmd = BM_APBH_CHn_CMD_WAIT4ENDCMD | BM_APBH_CHn_CMD_SEMAPHORE | BM_APBH_CHn_CMD_IRQONCMPLT | BF(0, APBH_CHn_CMD_XFER_COUNT) | BF(3, APBH_CHn_CMD_CMDWORDS) | BF(0, APBH_CHn_CMD_COMMAND); /* NO_DMA_XFER */
dma_desc->command->pio_words[0] = BM_SSP_CTRL0_ENABLE |
BM_SSP_CTRL0_IGNORE_CRC;
dma_desc->command->pio_words[1] = BF(cmd->opcode, SSP_CMD0_CMD) |
BM_SSP_CMD0_APPEND_8CYC;
dma_desc->command->pio_words[2] = BF(cmd->arg, SSP_CMD1_CMD_ARG);
init_completion(&host->dma_done);
stmp3xxx_dma_reset_channel(host->dmach);
stmp3xxx_dma_go(host->dmach, dma_desc, 1);
wait_for_completion(&host->dma_done);
cmd->error = stmp3xxx_mmc_cmd_error(host->status);
if (stmp3xxx_dma_running(host->dmach))
dev_dbg(host->dev, "DMA command not finished\n");
if (cmd->error) {
dev_dbg(host->dev, "Command error 0x%x\n", cmd->error);
stmp3xxx_dma_reset_channel(host->dmach);
}
}
示例5: insert
node * insert(node *T,int x)
{
if(T==NULL)
{
T=(node*)malloc(sizeof(node));
T->data=x;
T->left=NULL;
T->right=NULL;
}
else
if(x > T->data) // insert in right subtree
{
T->right=insert(T->right,x);
if(BF(T)==-2)
if(x>T->right->data)
T=RR(T);
else
T=RL(T);
}
else
if(x<T->data)
{
T->left=insert(T->left,x);
if(BF(T)==2)
if(x < T->left->data)
T=LL(T);
else
T=LR(T);
}
T->ht=height(T);
return(T);
}
示例6: stmp37xx_circ_advance_active
void stmp37xx_circ_advance_active(struct stmp37xx_circ_dma_chain *chain,
unsigned count)
{
void __iomem *c;
u32 mask_clr, mask;
BUG_ON(chain->free_count < count);
chain->free_count -= count;
chain->free_index += count;
chain->free_index %= chain->total_count;
chain->active_count += count;
switch (chain->bus) {
case STMP3XXX_BUS_APBH:
c = REGS_APBH_BASE + HW_APBH_CHn_SEMA + 0x70 * chain->channel;
mask_clr = BM_APBH_CHn_SEMA_INCREMENT_SEMA;
mask = BF(count, APBH_CHn_SEMA_INCREMENT_SEMA);
break;
case STMP3XXX_BUS_APBX:
c = REGS_APBX_BASE + HW_APBX_CHn_SEMA + 0x70 * chain->channel;
mask_clr = BM_APBX_CHn_SEMA_INCREMENT_SEMA;
mask = BF(count, APBX_CHn_SEMA_INCREMENT_SEMA);
break;
default:
BUG();
return;
}
/* Set counting semaphore (kicks off transfer). Assumes
peripheral has been set up correctly */
stmp3xxx_clearl(mask_clr, c);
stmp3xxx_setl(mask, c);
}
示例7: set_otp_timing
static int set_otp_timing(void)
{
u32 clk_rate = 0;
u32 relax, strobe_read, strobe_prog;
u32 timing = 0;
/* get clock */
clk_rate = mxc_get_clock(MXC_IPG_CLK);
if (clk_rate == -1) {
printf("ERROR: mxc_get_clock failed\n");
return -1;
}
log("clk_rate: %d.", clk_rate);
relax = clk_rate / (1000000000 / DEF_RELAX) - 1;
strobe_prog = clk_rate / (1000000000 / 10000) + 2 * (DEF_RELAX + 1) - 1;
strobe_read = clk_rate / (1000000000 / 40) + 2 * (DEF_RELAX + 1) - 1;
timing = BF(relax, OCOTP_TIMING_RELAX);
timing |= BF(strobe_read, OCOTP_TIMING_STROBE_READ);
timing |= BF(strobe_prog, OCOTP_TIMING_STROBE_PROG);
log("timing: 0x%X", timing);
writel(timing, IMX_OTP_BASE + HW_OCOTP_TIMING);
return 0;
}
示例8: timing_ctrl_rams
int timing_ctrl_rams(int ss)
{
__raw_writel(BF(ss, DIGCTL_ARMCACHE_VALID_SS) |
BF(ss, DIGCTL_ARMCACHE_DRTY_SS) |
BF(ss, DIGCTL_ARMCACHE_CACHE_SS) |
BF(ss, DIGCTL_ARMCACHE_DTAG_SS) |
BF(ss, DIGCTL_ARMCACHE_ITAG_SS),
DIGCTRL_BASE_ADDR + HW_DIGCTL_ARMCACHE);
return 0;
}
示例9: stmp3xxx_set_sclk_speed
/*
* Change divisors to reflect the rate of 'hz'. Note that we should not
* play with clock rate, because the same source is used to clock both
* SSP ports.
*/
static void
stmp3xxx_set_sclk_speed(struct stmp3xxx_mmc_host *host, unsigned int hz)
{
unsigned long ssp;
u32 div1, div2;
u32 val;
struct stmp3xxxmmc_platform_data *pdata = host->dev->platform_data;
if (get_evk_board_version() == 1) {
/*EVK Ver1 max clock is 12M */
if (hz > 12000000)
hz = 12000000;
}
if (pdata && pdata->setclock) {
/*
if the SSP is buggy and platform provides callback...
well, let it be.
*/
host->clkrt = pdata->setclock(hz);
return;
}
/*
...but the RightIdea(tm) is to set divisors to match
the requested clock.
*/
hz /= 1000;
ssp = clk_get_rate(host->clk);
for (div1 = 2; div1 < 254; div1 += 2) {
div2 = ssp / hz / div1;
if (div2 < 0x100)
break;
}
if (div1 >= 254) {
dev_err(host->dev, "Cannot set clock to %dkHz\n", hz);
return;
}
dev_dbg(host->dev, "Setting clock rate to %ld kHz [%x+%x] "
"(requested %d), source %ldk\n",
ssp / div1 / div2, div1, div2, hz, ssp);
val = __raw_readl(host->ssp_base + HW_SSP_TIMING);
val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
val |= BF(div1, SSP_TIMING_CLOCK_DIVIDE) |
BF(div2 - 1, SSP_TIMING_CLOCK_RATE);
__raw_writel(val, host->ssp_base + HW_SSP_TIMING);
host->clkrt = ssp / div1 / div2 * 1000;
}
示例10: Delete
node * Delete(node *T,int x)
{ node *p;
if(T==NULL)
{
return NULL;
}
else
if(x > T->data) // insert in right subtree
{
T->right=Delete(T->right,x);
if(BF(T)==2)
if(BF(T->left)>=0)
T=LL(T);
else
T=LR(T);
}
else
if(x<T->data)
{
T->left=Delete(T->left,x);
if(BF(T)==-2)//Rebalance during windup
if(BF(T->right)<=0)
T=RR(T);
else
T=RL(T);
}
else
{
//data to be deleted is found
if(T->right !=NULL)
{ //delete its inordersuccesor
p=T->right;
while(p->left != NULL)
p=p->left;
T->data=p->data;
T->right=Delete(T->right,p->data);
if(BF(T)==2)//Rebalance during windup
if(BF(T->left)>=0)
T=LL(T);
else
T=LR(T);
}
else
return(T->left);
}
T->ht=height(T);
return(T);
}
示例11: if
static struct avl_node *_avl_delete(struct avl_node *n, int key)
{
if(!n) return NULL;
if(key < K(n)) L(n) = _avl_delete(L(n), key);
else if(key > K(n)) R(n) = _avl_delete(R(n), key);
else { // key == K(n)
if(NULL == L(n) || NULL == R(n)) {
struct avl_node *tmp = L(n) ? L(n) : R(n);
if(tmp) {
*n = *tmp; // copy contents of child to n
}
else { // n is leaf
tmp = n;
n = NULL;
}
free(tmp);
}
else { // two children case
struct avl_node *d = _avl_minimum(n);
K(n) = K(d);
R(n) = _avl_delete(d, key);
}
}
// no child case
if(!n) return NULL;
H(n) = MAX(HH(n->left), HH(n->right)) + 1;
int bf = BF(n);
if(bf > 1) {
if(0 > BF(L(n))) { // LR case
L(n) = _leftRotate(L(n));
}
// else LL case
return _rightRotate(n);
}
if(bf < -1) {
if(0 < BF(R(n))) { // RL case
R(n) = _rightRotate(R(n));
}
// else RR case
return _leftRotate(n);
}
return n;
}
示例12: evaluateFields
void CismSurfaceGradFO<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
for (std::size_t cell=0; cell < workset.numCells; ++cell) {
for (std::size_t qp=0; qp < numQPs; ++qp) {
gradS_qp(cell,qp,0) = dsdx_node(cell, 0) * BF(cell, 0, qp);
gradS_qp(cell,qp,1) = dsdy_node(cell, 0) * BF(cell, 0, qp);
for (std::size_t node=1; node < numNodes; ++node) {
gradS_qp(cell,qp,0) += dsdx_node(cell, node) * BF(cell, node, qp);
gradS_qp(cell,qp,1) += dsdy_node(cell, node) * BF(cell, node, qp);
}
}
}
}
示例13: testKNNG
bool testKNNG(unsigned int Size, unsigned int k, T min, T max, int num_threads)
{
typedef reviver::dpoint<T, DIM> Point;
std::vector<Point> data;
std::vector<long unsigned int> bf_ans;
data.resize(Size);
for(unsigned int i=0;i < data.size();++i)
{
data[i] = newRandomPoint<Point, T>(min, max);
}
bruteNN<Point> BF(&data[0], data.size());
sfcnn_knng<Point, DIM, T> SFC(&data[0], data.size(), k, num_threads);
for(unsigned int i=0;i < data.size();++i)
{
BF.ksearch(data[i], k+1, bf_ans);
for(unsigned int j=1;j < k+1;++j)
{
if(bf_ans[j] != SFC[i][j-1])
return false;
}
}
return true;
}
示例14: fuse_read_addr
static int fuse_read_addr(struct ocotp_priv *priv, u32 addr, u32 *pdata)
{
u32 ctrl_reg;
int ret;
writel(OCOTP_CTRL_ERROR, priv->base + OCOTP_CTRL_CLR);
ctrl_reg = readl(priv->base + OCOTP_CTRL);
ctrl_reg &= ~OCOTP_CTRL_ADDR_MASK;
ctrl_reg &= ~OCOTP_CTRL_WR_UNLOCK_MASK;
ctrl_reg |= BF(addr, OCOTP_CTRL_ADDR);
writel(ctrl_reg, priv->base + OCOTP_CTRL);
writel(OCOTP_READ_CTRL_READ_FUSE, priv->base + OCOTP_READ_CTRL);
ret = imx6_ocotp_wait_busy(priv, 0);
if (ret)
return ret;
if (readl(priv->base + OCOTP_CTRL) & OCOTP_CTRL_ERROR)
*pdata = 0xbadabada;
else
*pdata = readl(priv->base + OCOTP_READ_FUSE_DATA);
return 0;
}
示例15: NV30EXACheckComposite
Bool
NV30EXACheckComposite(int op, PicturePtr psPict,
PicturePtr pmPict,
PicturePtr pdPict)
{
nv_pict_surface_format_t *fmt;
nv_pict_op_t *opr;
opr = NV30_GetPictOpRec(op);
if (!opr)
NOUVEAU_FALLBACK("unsupported blend op 0x%x\n", op);
fmt = NV30_GetPictSurfaceFormat(pdPict->format);
if (!fmt)
NOUVEAU_FALLBACK("dst picture format 0x%08x not supported\n",
pdPict->format);
if (!NV30EXACheckCompositeTexture(psPict, pdPict, op))
NOUVEAU_FALLBACK("src picture\n");
if (pmPict) {
if (pmPict->componentAlpha &&
PICT_FORMAT_RGB(pmPict->format) &&
opr->src_alpha && opr->src_card_op != BF(ZERO))
NOUVEAU_FALLBACK("mask CA + SA\n");
if (!NV30EXACheckCompositeTexture(pmPict, pdPict, op))
NOUVEAU_FALLBACK("mask picture\n");
}
return TRUE;
}