您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CEILING函数代码示例

51自学网 2021-06-01 19:58:08
  C++
这篇教程C++ CEILING函数代码示例写得很实用,希望能帮到您。

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

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

示例1: Destroy_LU

/*! /brief Destroy distributed L & U matrices. */voidDestroy_LU(int_t n, gridinfo_t *grid, LUstruct_t *LUstruct){    int_t i, nb, nsupers;    Glu_persist_t *Glu_persist = LUstruct->Glu_persist;    LocalLU_t *Llu = LUstruct->Llu;#if ( DEBUGlevel>=1 )    int iam;    MPI_Comm_rank( MPI_COMM_WORLD, &iam );    CHECK_MALLOC(iam, "Enter Destroy_LU()");#endif    nsupers = Glu_persist->supno[n-1] + 1;    nb = CEILING(nsupers, grid->npcol);    for (i = 0; i < nb; ++i) 	if ( Llu->Lrowind_bc_ptr[i] ) {	    SUPERLU_FREE (Llu->Lrowind_bc_ptr[i]);#ifdef GPU_ACC	    checkCuda(cudaFreeHost(Llu->Lnzval_bc_ptr[i]));#else	    SUPERLU_FREE (Llu->Lnzval_bc_ptr[i]);#endif	}    SUPERLU_FREE (Llu->Lrowind_bc_ptr);    SUPERLU_FREE (Llu->Lnzval_bc_ptr);    nb = CEILING(nsupers, grid->nprow);    for (i = 0; i < nb; ++i)	if ( Llu->Ufstnz_br_ptr[i] ) {	    SUPERLU_FREE (Llu->Ufstnz_br_ptr[i]);	    SUPERLU_FREE (Llu->Unzval_br_ptr[i]);	}    SUPERLU_FREE (Llu->Ufstnz_br_ptr);    SUPERLU_FREE (Llu->Unzval_br_ptr);    /* The following can be freed after factorization. */    SUPERLU_FREE(Llu->ToRecv);    SUPERLU_FREE(Llu->ToSendD);    SUPERLU_FREE(Llu->ToSendR[0]);    SUPERLU_FREE(Llu->ToSendR);    /* The following can be freed only after iterative refinement. */    SUPERLU_FREE(Llu->ilsum);    SUPERLU_FREE(Llu->fmod);    SUPERLU_FREE(Llu->fsendx_plist[0]);    SUPERLU_FREE(Llu->fsendx_plist);    SUPERLU_FREE(Llu->bmod);    SUPERLU_FREE(Llu->bsendx_plist[0]);    SUPERLU_FREE(Llu->bsendx_plist);    SUPERLU_FREE(Llu->mod_bit);    SUPERLU_FREE(Glu_persist->xsup);    SUPERLU_FREE(Glu_persist->supno);#if ( DEBUGlevel>=1 )    CHECK_MALLOC(iam, "Exit Destroy_LU()");#endif}
开发者ID:DBorello,项目名称:OpenSeesDev,代码行数:61,


示例2: dQuerySpace_dist

/*! /brief * * <pre> * mem_usage consists of the following fields: *    - for_lu (float) *      The amount of space used in bytes for the L/U data structures. *    - total (float) *      The amount of space needed in bytes to perform factorization. *    - expansions (int) *      Number of memory expansions during the LU factorization. * </pre> */int_t dQuerySpace_dist(int_t n, LUstruct_t *LUstruct, gridinfo_t *grid,		       mem_usage_t *mem_usage){    register int_t dword, gb, iword, k, maxsup, nb, nsupers;    int_t *index, *xsup;    int iam, mycol, myrow;    Glu_persist_t *Glu_persist = LUstruct->Glu_persist;    LocalLU_t *Llu = LUstruct->Llu;    iam = grid->iam;    myrow = MYROW( iam, grid );    mycol = MYCOL( iam, grid );    iword = sizeof(int_t);    dword = sizeof(double);    maxsup = sp_ienv_dist(3);    nsupers = Glu_persist->supno[n-1] + 1;    xsup = Glu_persist->xsup;    mem_usage->for_lu = 0;    /* For L factor */    nb = CEILING( nsupers, grid->npcol ); /* Number of local column blocks */    for (k = 0; k < nb; ++k) {	gb = k * grid->npcol + mycol; /* Global block number. */	if ( gb < nsupers ) {	    index = Llu->Lrowind_bc_ptr[k];	    if ( index ) {		mem_usage->for_lu += (float)		    ((BC_HEADER + index[0]*LB_DESCRIPTOR + index[1]) * iword);		mem_usage->for_lu += (float)(index[1]*SuperSize( gb )*dword);	    }	}    }    /* For U factor */    nb = CEILING( nsupers, grid->nprow ); /* Number of local row blocks */    for (k = 0; k < nb; ++k) {	gb = k * grid->nprow + myrow; /* Global block number. */	if ( gb < nsupers ) {	    index = Llu->Ufstnz_br_ptr[k];	    if ( index ) {		mem_usage->for_lu += (float)(index[2] * iword);		mem_usage->for_lu += (float)(index[1] * dword);	    }	}    }    /* Working storage to support factorization */    mem_usage->total = mem_usage->for_lu;    mem_usage->total +=	(float)(( Llu->bufmax[0] + Llu->bufmax[2] ) * iword +		( Llu->bufmax[1] + Llu->bufmax[3] + maxsup ) * dword );    /**** another buffer to use mpi_irecv in pdgstrf_irecv.c ****/    mem_usage->total +=	(float)( Llu->bufmax[0] * iword +  Llu->bufmax[1] * dword );    mem_usage->total += (float)( maxsup * maxsup + maxsup) * iword;    k = CEILING( nsupers, grid->nprow );    mem_usage->total += (float)(2 * k * iword);    return 0;} /* dQuerySpace_dist */
开发者ID:DBorello,项目名称:OpenSees,代码行数:72,


示例3: sanity_check

char * sanity_check(){    // proof of correct ceilling macro    mu_assert(CEILING(7,4) == 2, "ceiling fail");    // proof of implicit floor    mu_assert(7/4  == 1, "floor fail");    mu_assert(1/2  == 0, "floor fail");    // proof of zero index    mu_assert(LEADINGBIT(4) ==  2  ,"FAIL");    mu_assert(LEADINGBIT(1) ==  0  ,"FAIL");    mu_assert(LEADINGBIT(8) ==  3  ,"FAIL");    index_t x,y, a = 0;    index_t data_size = 1, super_count = 0, super_last_count = 0, super_size=1, length = 30;    index_t ** index = malloc(length * sizeof(index_t));;    fflush(stdout);    //printf("/n");    for(x = 0 ; x < length; x++){        index[x] = malloc(data_size * sizeof(index_t));        for(y = 0; y < data_size; y++){            index[x][y]=a;            a++;            printf("%ld ", index[x][y]);        }        super_last_count++;        printf("/n");        if(super_last_count == super_size){            super_last_count = 0;            if(super_count%2){                super_size *=2;                super_count++;            } else {                    data_size *= 2;                super_count++;            }        }    }    //log_success("Finished element dump");    unsigned long int get_index(index_t i){        index_t r,k,b,e,p;       // log_info("Trying to get %ld", i);        r = i + 1;        k = LEADINGBIT(r); // no need for minus 1. already zero indexed PERFECT      //  log_info("k/2=%ld, Ceil(k,2)=%ld",k/2,CEILING(k,2));        b = BITSUBSET(r,k-k/2,k);        e = BITSUBSET(r,0, CEILING(k,2));        //p =  (1 << (k-1)) ; //PEFECT        p = (1 << (k/2 + 1)) - 2 + (k & 1) * (1 << (k/2));        //p = k==0 ? 0 :  (1 << k-1) ; //PEFECT        //p = (1 << k-1) ; //PEFECT        //log_info("K: %ld",k);        //log_info("B: %ld",b);        //log_info("E: %ld",e);        //log_info("P: %ld super blocks prior",p);        log_info("trying [%ld,%ld]",(p+b),e);        printf("p+b,e : [%ld,%ld] /n",p+b,e);        return index[(p+b)][e];    }
开发者ID:enjoylife,项目名称:DataMonkey,代码行数:59,


示例4: VMCI_AllocQueue

void *VMCI_AllocQueue(uint64 size) // IN: size of queue (not including header){    const uint64 numPages = CEILING(size, PAGE_SIZE);    VMCIQueue *queue;    queue = vmalloc(sizeof *queue + numPages * sizeof queue->page[0]);    if (queue) {        uint64 i;        /*         * Allocate physical pages, they will be mapped/unmapped on demand.         */        for (i = 0; i < numPages; i++) {            queue->page[i] = alloc_pages(GFP_KERNEL, 0); /* One page. */            if (!queue->page[i]) {                /*                 * Free all pages allocated.                 */                while (i) {                    __free_page(queue->page[--i]);                }                vfree(queue);                queue = NULL;                break;            }        }    }    return queue;}
开发者ID:ianw,项目名称:vmware-workstation-7,代码行数:30,


示例5: draw_custom_bootscreen

 FORCE_INLINE void draw_custom_bootscreen(const u8g_pgm_uint8_t * const bmp, const bool erase=true) {   constexpr u8g_uint_t left = (LCD_PIXEL_WIDTH  - (CUSTOM_BOOTSCREEN_BMPWIDTH)) / 2,                        top = (LCD_PIXEL_HEIGHT - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) / 2;   #if ENABLED(CUSTOM_BOOTSCREEN_INVERTED)     constexpr u8g_uint_t right = left + CUSTOM_BOOTSCREEN_BMPWIDTH,                         bottom = top + CUSTOM_BOOTSCREEN_BMPHEIGHT;   #endif   u8g.firstPage();   do {     u8g.drawBitmapP(       left, top,       CEILING(CUSTOM_BOOTSCREEN_BMPWIDTH, 8), CUSTOM_BOOTSCREEN_BMPHEIGHT, bmp     );     #if ENABLED(CUSTOM_BOOTSCREEN_INVERTED)       if (erase) {         u8g.setColorIndex(1);         if (top) u8g.drawBox(0, 0, LCD_PIXEL_WIDTH, top);         if (left) u8g.drawBox(0, top, left, CUSTOM_BOOTSCREEN_BMPHEIGHT);         if (right < LCD_PIXEL_WIDTH) u8g.drawBox(right, top, LCD_PIXEL_WIDTH - right, CUSTOM_BOOTSCREEN_BMPHEIGHT);         if (bottom < LCD_PIXEL_HEIGHT) u8g.drawBox(0, bottom, LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT - bottom);       }     #else       UNUSED(erase);     #endif   } while (u8g.nextPage()); }
开发者ID:szymonrychu,项目名称:Marlin,代码行数:26,


示例6: win_occpuants_cols

intwin_occpuants_cols(void){    int occupants_win_percent = prefs_get_occupants_size();    int cols = getmaxx(stdscr);    return CEILING( (((double)cols) / 100) * occupants_win_percent);}
开发者ID:sizeofvoid,项目名称:profanity,代码行数:7,


示例7: win_roster_cols

intwin_roster_cols(void){    int roster_win_percent = prefs_get_roster_size();    int cols = getmaxx(stdscr);    return CEILING( (((double)cols) / 100) * roster_win_percent);}
开发者ID:sizeofvoid,项目名称:profanity,代码行数:7,


示例8: get_nof_cb

int get_nof_cb(int recv_bits, int *nof_short_cb, int *nof_long_cb,		int *len_short_cb, int *len_long_cb, int *nof_filler_bits) {	int num_cb;	int i, Bp, Ak;	/** Calculate Number of output code blocks*/	if (recv_bits <= Z) {		num_cb = 1;		*nof_long_cb = 1;		*nof_short_cb = 0;		*len_short_cb = 0;		if (recv_bits < 40) {			*len_long_cb = 40;			*nof_filler_bits = Bmin - recv_bits;		} else {			*len_long_cb = recv_bits;			*nof_filler_bits = 0;		}	}	if (recv_bits > Z) {		num_cb = CEILING((float)recv_bits/(float)(Z - L));		Bp = recv_bits + num_cb * L;		/** Calculate code block sizes*/		for (i = 1; i < 189; i++) {			/** First Segmentation size: K+*/			*len_long_cb = Table5133[i];			/** Second Segmentation Size: K-*/			*len_short_cb = Table5133[i - 1];			if (Table5133[i] * num_cb >= Bp) {				break;			}		}		if (num_cb == 1) {			/** C+ :Number of segments of size K+ (Kp)*/			*nof_long_cb = 1;			*len_short_cb = 0; /** K- */			/** C- :Number of segments of size K- (Km)*/			*nof_short_cb = 0;			/** Number of Filler Bits*/			*nof_filler_bits = Bmin - recv_bits;		}		if (num_cb > 1) {			Ak = *len_long_cb - *len_short_cb;			*nof_short_cb = (int) floor(					((float) (num_cb * *len_long_cb) - Bp) / (float) Ak);			*nof_long_cb = num_cb - *nof_short_cb;			/** Number of Filler Bits*/			*nof_filler_bits = *nof_long_cb * *len_long_cb					+ *nof_short_cb * *len_short_cb - Bp;		}		*len_long_cb = *len_long_cb - 24;		if (*len_short_cb > 0)			*len_short_cb = *len_short_cb - 24;	}	return num_cb;}
开发者ID:KrishnaAdapa,项目名称:aloe,代码行数:59,


示例9: check_ablk

voidcheck_ablk(TestCaseState_t *tcs, Allctr_t *a, void *ptr, Ulong umem_sz){    Ulong unit_sz = UNIT_SZ;    Block_t *blk = UMEM2BLK(ptr);    Block_t *nxt_blk = NXT_BLK(blk);    Ulong real_sz = ((Ulong) nxt_blk) - ((Ulong) (blk));    ASSERT(tcs, real_sz == BLK_SZ(blk));    ASSERT(tcs, !IS_FREE_BLK(blk));    ASSERT(tcs, real_sz >= CEILING(ABLK_HDR_SZ + umem_sz, unit_sz));    if (real_sz > MIN_BLK_SZ(a)	&& real_sz > CEILING(ABLK_HDR_SZ+umem_sz, unit_sz)) {	ASSERT(tcs,	       real_sz <= CEILING(MIN_BLK_SZ(a)+ABLK_HDR_SZ+umem_sz,				  unit_sz));	ASSERT(tcs, IS_LAST_BLK(blk) || !IS_FREE_BLK(nxt_blk));    }}
开发者ID:Andy-Richards,项目名称:otp,代码行数:18,


示例10: __gnix_rma_fill_pd_indirect_get

static void __gnix_rma_fill_pd_indirect_get(struct gnix_fab_req *req,					    struct gnix_tx_descriptor *txd){	int head_off = req->rma.rem_addr & GNI_READ_ALIGN_MASK;	/* Copy all data through an intermediate buffer. */	txd->gni_desc.local_addr = (uint64_t)txd->int_buf;	txd->gni_desc.local_mem_hndl = req->vc->ep->nic->int_bufs_mdh;	txd->gni_desc.length = CEILING(req->rma.len + head_off, GNI_READ_ALIGN);	txd->gni_desc.remote_addr =			(uint64_t)req->rma.rem_addr & ~GNI_READ_ALIGN_MASK;}
开发者ID:metalpine,项目名称:libfabric,代码行数:12,


示例11: flex_compare

extern inline DSTATUS flex_compare(flex_t flex, index_t requested_index, data_p user_data){    index_t r,k,b,e,p;    r = requested_index + 1;    k = LEADINGBIT(r); // no need for minus 1. already zero indexed     b = BITSUBSET(r,k-k/2,k);    e = BITSUBSET(r,0, CEILING(k,2));    p = (1 << (k/2 + 1)) - 2 + (k & 1) * (1 << (k/2));    if(p+b > flex->last_index_occup){ // we have an index which would seg fault        return FAILURE;    }     return (flex->cmp_func(&(flex->index_block[(p+b)][e]), user_data));}
开发者ID:enjoylife,项目名称:DataMonkey,代码行数:13,


示例12: flex_get

extern inline data_p flex_get(flex_t flex, index_t requested_index){    index_t r,k,b,e,p;    r = requested_index + 1;    k = LEADINGBIT(r); // no need for minus 1. already zero indexed     b = BITSUBSET(r,k-k/2,k);    e = BITSUBSET(r,0, CEILING(k,2));    p = (1 << (k/2 + 1)) - 2 + (k & 1) * (1 << (k/2));    if(p+b > flex->last_index_occup){ // we have an index which would seg fault        return NULL;    }     return &flex->index_block[(p+b)][e];}
开发者ID:enjoylife,项目名称:DataMonkey,代码行数:13,


示例13: iso9660_ifs_readdir

void DVDRipper::find_start_blocks() {   CdioList_t *p_entlist;   CdioListNode_t *p_entnode;      if (!p_iso)      return;      p_entlist = iso9660_ifs_readdir (p_iso, "/video_ts/");      if (p_entlist) {      _CDIO_LIST_FOREACH (p_entnode, p_entlist) {	 unsigned long long start;	 unsigned long long blocks;	 	 char filename[4096];	 int len;	 	 iso9660_stat_t *p_statbuf =	    (iso9660_stat_t *) _cdio_list_node_data (p_entnode);	 iso9660_name_translate(p_statbuf->filename, filename);	 len = strlen(filename);	 	 if (!(2 == p_statbuf->type) ) {	    if (! strcmp(filename + (len-3), "vob")) {	       start = p_statbuf->lsn;	       blocks = CEILING(p_statbuf->size, DVDCSS_BLOCK_SIZE);	       	       start_map[start] = strdup(filename);	       if (blocks == 0) {		  //file length of 0 would result in a blocks of 0, and don't want		  //to subtract one from it.		  end_blocks[start] = start;	       } else {		  //-1 as start block is included in count of blocks		  end_blocks[start] = start - 1 + blocks;	       }	       	       printf("%s: %llu->%llu (%llu blocks)/n", filename, start, end_blocks[start], blocks);	       	       if (blocks) {		  if (find(start_blocks.begin(), start_blocks.end(), start) == start_blocks.end()) {		     start_blocks.push_back(start);		  }	       }	    }	 }      }            _cdio_list_free (p_entlist, true);   }
开发者ID:sjpotter,项目名称:dvdripper,代码行数:51,


示例14: flex_delete

extern inline DSTATUS flex_delete(flex_t flex, index_t requested_index){    index_t r,k,b,e,p;    r = requested_index + 1;    k = LEADINGBIT(r); // no need for minus 1. already zero indexed     b = BITSUBSET(r,k-k/2,k);    e = BITSUBSET(r,0, CEILING(k,2));    p = (1 << (k/2 + 1)) - 2 + (k & 1) * (1 << (k/2));    if(p+b > flex->last_index_occup){ // we have an index which would seg fault        return FAILURE;    }     flex->index_block[(p+b)][e] = 0;    return SUCCESS;}
开发者ID:enjoylife,项目名称:DataMonkey,代码行数:14,


示例15: VMCI_FreeQueue

voidVMCI_FreeQueue(void *q,     // IN:               uint64 size) // IN: size of queue (not including header){    VMCIQueue *queue = q;    if (queue) {        uint64 i;        for (i = 0; i < CEILING(size, PAGE_SIZE); i++) {            __free_page(queue->page[i]);        }        vfree(queue);    }}
开发者ID:ianw,项目名称:vmware-workstation-7,代码行数:15,


示例16: getGDGT

static boolgetGDGT(SparseGTInfo *gtInfo,        const SparseExtentHeader *hdr){	if (hdr->grainSize < 1 || hdr->grainSize > 128 || !isPow2(hdr->grainSize)) {		return false;	}	/* disklib supports only 512 GTEs per GT (=> 4KB GT size).  Streaming is more flexible. */	if (hdr->numGTEsPerGT < VMDK_SECTOR_SIZE / sizeof(uint32_t) || !isPow2(hdr->numGTEsPerGT)) {		return false;	}	gtInfo->lastGrainNr = hdr->capacity / hdr->grainSize;	gtInfo->lastGrainSize = (hdr->capacity & (hdr->grainSize - 1)) * VMDK_SECTOR_SIZE;	{		uint64_t GTEs = gtInfo->lastGrainNr + (gtInfo->lastGrainSize != 0);		/* Number of GTEs must be less than 2^32.  Actually capacity must be less than 2^32 (2TB) for everything except streamOptimized format... */		uint32_t GTs = CEILING(GTEs, hdr->numGTEsPerGT);		uint32_t GDsectors = CEILING(GTs * sizeof(uint32_t), VMDK_SECTOR_SIZE);		uint32_t GTsectors = CEILING(hdr->numGTEsPerGT * sizeof(uint32_t), VMDK_SECTOR_SIZE);		uint32_t *gd = calloc(GDsectors + GTsectors * GTs, VMDK_SECTOR_SIZE);		uint32_t *gt;		if (!gd) {			return false;		}		gt = gd + GDsectors * VMDK_SECTOR_SIZE / sizeof(uint32_t);		gtInfo->GTEs = GTEs;		gtInfo->GTs = GTs;		gtInfo->GDsectors = GDsectors;		gtInfo->gd = gd;		gtInfo->GTsectors = GTsectors;		gtInfo->gt = gt;	}	return true;}
开发者ID:markpeek,项目名称:open-vmdk,代码行数:36,


示例17: flex_shrink

/* Reduces the internal counters to our array, and subtracts one from the count of contained application elements. * --------------------------------------------------------------------------------------------------------------- * [params] {flex} a nonvoid flex array to work with. * [return] {SUCCESS} if shrinking was completed. *          {FAILURE} if array is shrunk to 0 elements, or if  memory error was encountered. */extern inline DSTATUS flex_shrink(flex_t  flex){    if(flex->num_user_elements_inserted == 0  )return FAILURE; // bail early    //log_info("test %ld == %ld",flex->usable_data_blocks - flex->last_data_size, flex->num_user_elements_inserted-1);    if(flex->num_user_elements_inserted != 1 &&             flex->usable_data_blocks - flex->last_data_size == flex->num_user_elements_inserted-1){        //log_info("REMOVED  @ %ld",flex->last_index_occup);        free(flex->index_block[flex->last_index_occup]);        flex->usable_data_blocks -= flex->last_data_size;        //log_info("realloc %ld == %ld",flex->last_index_occup*2, flex->index_length);        if((flex->last_index_occup) *2 ==  flex->index_length ){ //TODO! see grow x=4 and x=7            flex->index_length =CEILING(flex->index_length,2);            index_p new_index = realloc(flex->index_block,                        sizeof(index_p) * flex->index_length);            check(new_index,"Failed in Shrinking flex");            flex->index_block = new_index;        }        flex->last_index_occup--;                //log_info("size change 0 == %ld",flex->last_super_occup);        if( 0== flex->last_super_occup){            flex->num_super_blocks--;            // if odd, cut data            if(flex->num_super_blocks % 2){                //log_info("cut data size");                flex->last_data_size /= 2;                //flex->last_data_size = CEILING(flex->last_data_size,2);            } else {                //log_info("cut super size");                flex->last_super_size /= 2;                //flex->last_super_size = CEILING(flex->last_super_size,2);            }            flex->last_super_occup = flex->last_super_size;            flex->last_super_occup--;        } else {            flex->last_super_occup--;        }        flex->num_user_elements_inserted--;    }  else {    flex->num_user_elements_inserted--;        return SUCCESS;    }error:    return FAILURE;}
开发者ID:enjoylife,项目名称:DataMonkey,代码行数:53,


示例18: dPrintLblocks

/*  * Print the blocks in the factored matrix L. */void dPrintLblocks(int_t iam, int_t nsupers, gridinfo_t *grid,		  Glu_persist_t *Glu_persist, LocalLU_t *Llu){    register int_t c, extra, gb, j, lb, nsupc, nsupr, len, nb, ncb;    register int_t k, mycol, r;    int_t *xsup = Glu_persist->xsup;    int_t *index;    double *nzval;    printf("/n(%d) L BLOCKS IN COLUMN-MAJOR ORDER -->/n", iam);    ncb = nsupers / grid->npcol;    extra = nsupers % grid->npcol;    mycol = MYCOL( iam, grid );    if ( mycol < extra ) ++ncb;    for (lb = 0; lb < ncb; ++lb) {	index = Llu->Lrowind_bc_ptr[lb];	if ( index ) { /* Not an empty column */	    nzval = Llu->Lnzval_bc_ptr[lb];	    nb = index[0];	    nsupr = index[1];	    gb = lb * grid->npcol + mycol;	    nsupc = SuperSize( gb );	    printf("(%d) block column (local) %d, # row blocks %d/n",		   iam, lb, nb);	    for (c = 0, k = BC_HEADER, r = 0; c < nb; ++c) {		len = index[k+1];		printf("(%d) row-block %d: block # %d/tlength %d/n", 		       iam, c, index[k], len);		PrintInt10("lsub", len, &index[k+LB_DESCRIPTOR]);		for (j = 0; j < nsupc; ++j) {		    PrintDouble5("nzval", len, &nzval[r + j*nsupr]);		}		k += LB_DESCRIPTOR + len;		r += len;	    }	}	printf("(%d)", iam); 	PrintInt10("ToSendR[]", grid->npcol, Llu->ToSendR[lb]);	PrintInt10("fsendx_plist[]", grid->nprow, Llu->fsendx_plist[lb]);    }    printf("nfrecvx %4d/n", Llu->nfrecvx);    k = CEILING( nsupers, grid->nprow );    PrintInt10("fmod", k, Llu->fmod);    } /* DPRINTLBLOCKS */
开发者ID:DBorello,项目名称:OpenSees,代码行数:48,


示例19: makeDiskDescriptorFile

static char *makeDiskDescriptorFile(const char *fileName,                       uint64_t capacity,                       uint32_t cid){	static const char ddfTemplate[] ="# Disk DescriptorFile/n""version=1/n""encoding=/"UTF-8/"/n""CID=%08x/n""parentCID=ffffffff/n""createType=/"streamOptimized/"/n""/n""# Extent description/n""RW %llu SPARSE /"%s/"/n""/n""# The Disk Data Base/n""#DDB/n""/n""ddb.longContentID = /"%08x%08x%08x%08x/"/n""ddb.toolsVersion = /"2147483647/"/n" /* OpenSource Tools version. */"ddb.virtualHWVersion = /"4/"/n" /* This field is obsolete, used by ESX3.x and older only. */"ddb.geometry.cylinders = /"%u/"/n""ddb.geometry.heads = /"255/"/n" /* 255/63 is good for anything bigger than 4GB. */"ddb.geometry.sectors = /"63/"/n""ddb.adapterType = /"lsilogic/"/n";	char *ret;	unsigned int cylinders;	if (capacity > 65535 * 255 * 63) {		cylinders = 65535;	} else {		cylinders = CEILING(capacity, 255 * 63);	}	if (asprintf(&ret, ddfTemplate, cid, (long long int)capacity, fileName, (uint32_t)mrand48(), (uint32_t)mrand48(), (uint32_t)mrand48(), cid, cylinders) == -1) {		return NULL;	}	return ret;}
开发者ID:markpeek,项目名称:open-vmdk,代码行数:40,


示例20: flex_insert

extern inline DSTATUS flex_insert(flex_t flex, index_t requested_index, data_p user_data){    DSTATUS status;    index_t r,k,b,e,p;    r = requested_index + 1;    k = LEADINGBIT(r); // no need for minus 1. already zero indexed     b = BITSUBSET(r,k-k/2,k);    e = BITSUBSET(r,0, CEILING(k,2));    p = (1 << (k/2 + 1)) - 2 + (k & 1) * (1 << (k/2));    //log_info("Grow Check P+B:[%ld], index: [%ld]",p+b, flex->index_length);    //printf("k/2=[%ld], Ceil(k,2)=[%ld]/n",k/2,CEILING(k,2));    //printf("K: [%ld] is the leading 1 bit/n",k); // printf("B: [%ld]/n",b);    while(p+b > flex->last_index_occup){ // we have an index which would seg fault        status = flex_grow(flex);  //flex_debug_out(flex);        check_alt(status == SUCCESS);        }    //log_info("trying [%ld,%ld]",(p+b),e);    (flex->index_block[(p+b)][e]) = *user_data;    return SUCCESS;error:    return FAILURE;}
开发者ID:enjoylife,项目名称:DataMonkey,代码行数:22,


示例21: __page_count

/** * Determine how many pages need to be allocated. * * @param[in] handle	Handle to the allocator being used. * * @return Number of pages that need to be allocated rounded up to the nearest * multiple of the page size. */static size_t __page_count(struct gnix_mbox_alloc_handle *handle){	size_t total_size = CEILING((handle->mbox_size * handle->mpmmap),				     handle->page_size);	size_t page_count;	page_count = total_size / handle->page_size;	GNIX_DEBUG(FI_LOG_EP_CTRL,		   "Mbox_size: %zu, mpmmap: %zu, page_size: %zu/n",		   handle->mbox_size, handle->mpmmap, handle->page_size);	GNIX_DEBUG(FI_LOG_EP_CTRL,		   "Total size: %zu, page_count: %zu/n", total_size,		   page_count);	if (page_count <= 0) {		GNIX_WARN(FI_LOG_EP_CTRL,			  "Invalid size requested, truncating to single page./n");		page_count = 1;	}	return page_count;}
开发者ID:ashleypittman,项目名称:libfabric,代码行数:32,


示例22: gluScaleImage

GLint gluScaleImage( GLenum format,                     GLint widthin, GLint heightin,                     GLenum typein, const void *datain,                     GLint widthout, GLint heightout,                     GLenum typeout, void *dataout ){   GLuint components, i, j, k;   GLfloat *tempin, *tempout;   GLfloat sx, sy;   GLint unpackrowlength, unpackalignment, unpackskiprows, unpackskippixels;   GLint packrowlength, packalignment, packskiprows, packskippixels;   GLint sizein, sizeout;   GLint rowstride, rowlen;   /* Determine number of components per pixel */   switch (format) {      case GL_COLOR_INDEX:      case GL_STENCIL_INDEX:      case GL_DEPTH_COMPONENT:      case GL_RED:      case GL_GREEN:      case GL_BLUE:      case GL_ALPHA:      case GL_LUMINANCE:         components = 1;	 break;      case GL_LUMINANCE_ALPHA:	 components = 2;	 break;      case GL_RGB:	 components = 3;	 break;      case GL_RGBA:	 components = 4;	 break;      default:	 return GLU_INVALID_ENUM;   }   /* Determine bytes per input datum */   switch (typein) {      case GL_UNSIGNED_BYTE:	sizein = sizeof(GLubyte);	break;      case GL_BYTE:		sizein = sizeof(GLbyte);	break;      case GL_UNSIGNED_SHORT:	sizein = sizeof(GLushort);	break;      case GL_SHORT:		sizein = sizeof(GLshort);	break;      case GL_UNSIGNED_INT:	sizein = sizeof(GLuint);	break;      case GL_INT:		sizein = sizeof(GLint);		break;      case GL_FLOAT:		sizein = sizeof(GLfloat);	break;      case GL_BITMAP:	 /* not implemented yet */      default:	 return GL_INVALID_ENUM;   }   /* Determine bytes per output datum */   switch (typeout) {      case GL_UNSIGNED_BYTE:	sizeout = sizeof(GLubyte);	break;      case GL_BYTE:		sizeout = sizeof(GLbyte);	break;      case GL_UNSIGNED_SHORT:	sizeout = sizeof(GLushort);	break;      case GL_SHORT:		sizeout = sizeof(GLshort);	break;      case GL_UNSIGNED_INT:	sizeout = sizeof(GLuint);	break;      case GL_INT:		sizeout = sizeof(GLint);	break;      case GL_FLOAT:		sizeout = sizeof(GLfloat);	break;      case GL_BITMAP:	 /* not implemented yet */      default:	 return GL_INVALID_ENUM;   }   /* Get glPixelStore state */   glGetIntegerv( GL_UNPACK_ROW_LENGTH, &unpackrowlength );   glGetIntegerv( GL_UNPACK_ALIGNMENT, &unpackalignment );   glGetIntegerv( GL_UNPACK_SKIP_ROWS, &unpackskiprows );   glGetIntegerv( GL_UNPACK_SKIP_PIXELS, &unpackskippixels );   glGetIntegerv( GL_PACK_ROW_LENGTH, &packrowlength );   glGetIntegerv( GL_PACK_ALIGNMENT, &packalignment );   glGetIntegerv( GL_PACK_SKIP_ROWS, &packskiprows );   glGetIntegerv( GL_PACK_SKIP_PIXELS, &packskippixels );   /* Allocate storage for intermediate images */   tempin = (GLfloat *) malloc( widthin * heightin			        * components * sizeof(GLfloat) );   if (!tempin) {      return GLU_OUT_OF_MEMORY;   }   tempout = (GLfloat *) malloc( widthout * heightout		 	         * components * sizeof(GLfloat) );   if (!tempout) {      free( tempin );      return GLU_OUT_OF_MEMORY;   }   /*    * Unpack the pixel data and convert to floating point    */   if (unpackrowlength>0) {      rowlen = unpackrowlength;//.........这里部分代码省略.........
开发者ID:alexjordan,项目名称:patmos-benchmarks,代码行数:101,


示例23: __battery_param_udpate

static BOOL __battery_param_udpate(struct battery_type *battery){	static int batt_id_stable_counter = 0;	INT32 batt_id_index;	INT32 temp_01c;	if (support_ds2746_gauge_ic) {		/* adc register value are read from __ds2746_battery_adc_udpate()*/		if (!__ds2746_battery_adc_udpate(battery))			return FALSE;	}	else{		/* adc register value are read from BAHW_get_batt_info_all()		if ( !BAHW_get_batt_info_all(battery) ) return FALSE;*/	}	/*real physical value*/	battery->voltage_mV = (battery->voltage_adc * voltage_adc_to_mv_coef / voltage_adc_to_mv_resl);	battery->current_mA = (battery->current_adc * current_adc_to_mv_coef / current_adc_to_mv_resl);	battery->discharge_mA = (battery->discharge_adc * discharge_adc_to_mv_coef / discharge_adc_to_mv_resl);	battery->charge_counter_mAh = (battery->charge_counter_adc * acr_adc_to_mv_coef / acr_adc_to_mv_resl) -	charge_counter_zero_base_mAh;	battery->current_mA = battery->current_mA - battery->discharge_mA;	/* prevent from adc out of range*/	if (battery->id_adc >= id_adc_resl) {		battery->id_adc = id_adc_resl - 1;	}	if (battery->id_adc <= 0) {		battery->id_adc = 1;	}	if (battery->temp_adc >= temp_adc_resl) {		battery->temp_adc = temp_adc_resl - 1;	}	if (battery->temp_adc <= 0) {		battery->temp_adc = 1;	}	/* battery ID shall be ready first for temp/kadc calculation*/	//   if ( id_conversion ) battery->id_ohm = ((float)id_R_kohm / ((float)id_adc_resl/battery->id_adc - 1)) * 1000;     // kohm -> ohm	//   else   			  battery->id_ohm = battery->id_adc;	battery->id_ohm = battery->id_adc;	calibrate_id_ohm(battery);	batt_id_index = get_id_index(battery);	if (is_allow_batt_id_change) {		/*! TODO: batt_id changes immediately; may need to modify in future*/		if (batt_id_stable_counter >= 3 && batt_id_index != battery->id_index){			/* if batt_id is stable but is different from previous one*/			batt_id_stable_counter = 0; /* reset stable counter and set batt_id to new one*/		}	}	if (batt_id_stable_counter < 3) {		if (batt_id_stable_counter == 0) {			/* first time to get the batt id*/			battery->id_index = batt_id_index;			battery->charge_full_design_mAh = FL_25[battery->id_index];			battery->charge_full_real_mAh = battery->charge_full_design_mAh;			batt_id_stable_counter = 1;		}		else{			/* 2nd and further time to get the batt id*/			if (batt_id_index == battery->id_index)				batt_id_stable_counter++;			else				batt_id_stable_counter = 0;		}	}	/* calculate temperature*/	//    battery->temp_01c 			  = get_temp_c((float)temp_R_kohm / ((float)temp_adc_resl/battery->temp_adc - 1))*10;	temp_01c = get_temp_01c(battery);	if (temp_01c >= TEMP_MIN*10)		battery->temp_01c = temp_01c;	else		printk(DRIVER_ZONE " get temp_01c(%d) failed.../n", temp_01c);	battery->temp_index = get_temp_index(battery);	/* calculate KADC and RARC*/	battery->KADC_01p = CEILING(get_kadc_001p(battery), 10);	battery->RARC_01p = CEILING(10000 * battery->charge_counter_mAh / battery->charge_full_real_mAh, 10);	if (!support_ds2746_gauge_ic) {		__software_acr_update(battery);	}	if (battery->voltage_mV <BATTERY_VOLTAGE_MIN ||		battery->voltage_mV> BATTERY_VOLTAGE_MAX) {		printk(DRIVER_ZONE " invalid V(%d)./n", battery->voltage_mV);		return FALSE;	}	/*! star_lee 20100426 - minimum RARC is 0%*/	if (battery->RARC_01p <= 0) {		battery->RARC_01p = 0;	}	printk(DRIVER_ZONE " V=%d(%x) I=%d(%x) C=%d.%d/%d(%x) id=%d(%x) T=%d(%x) KADC=%d/n",		battery->voltage_mV,		battery->voltage_adc,		battery->current_mA,//.........这里部分代码省略.........
开发者ID:marc1706,项目名称:hd2_kernel,代码行数:101,


示例24: networkRoute_Handler

/*- RouteRead --------------------------------------------------*/void networkRoute_Handler(OPERATION_HEADER_t* operation_header){	if(operation_header->opCode == RouteTableRead)	{				routeTableResponse.header.sourceAddress = runningConfiguration.topConfiguration.networkConfig.deviceAddress;		routeTableResponse.header.destinationAddress = operation_header->sourceAddress;				if(readRouteSession.sendingState && operation_header->sourceAddress != readRouteSession.destinationAddress)		{			//BUSY SENDING CONFIG STATE			routeTableResponse.response.fragment = 0;			routeTableResponse.response.fragmentTotal = 0;			routeTableResponse.response.length = 0;		}else		{			NWK_CopyRouteTable(&routeTableBuffer, currentTableSize);						readRouteSession.sendingState = true;			readRouteSession.destinationAddress = operation_header->sourceAddress;						readRouteSession.currentSendIndex = 0;			readRouteSession.currentSendFragment = 0;			readRouteSession.totalSendExpected = CEILING(currentTableSize , MAX_CONTENT_MESSAGE_SIZE);			readRouteSession.currentSendFrameSize = MIN(MAX_CONTENT_MESSAGE_SIZE, currentTableSize - readRouteSession.currentSendIndex);						routeTableResponse.response.fragment = readRouteSession.currentSendFragment;			routeTableResponse.response.fragmentTotal = readRouteSession.totalSendExpected;			routeTableResponse.response.length = readRouteSession.currentSendFrameSize;						OM_ProccessResponseWithBodyOperation(&routeTableResponse.header, readRouteSession.readBuffer, readRouteSession.currentSendFrameSize);		}	}else if(operation_header->opCode == RouteTableReadConfirmation)	{		if(readRouteSession.sendingState)		{			ROUTE_TABLE_READ_CONFIRMATION_MESSAGE_t* msg = (ROUTE_TABLE_READ_CONFIRMATION_MESSAGE_t*)(operation_header + 1);						if(msg->fragment == readRouteSession.currentSendFragment && msg->fragmentTotal == readRouteSession.totalSendExpected)			{				if(msg->code == 0x00) //'OK'				{					if(readRouteSession.currentSendFragment <= readRouteSession.totalSendExpected)	 //Something to send					{						readRouteSession.currentSendIndex += readRouteSession.currentSendFrameSize;						readRouteSession.currentSendFragment++;												readRouteSession.currentSendFrameSize = MIN(MAX_CONTENT_MESSAGE_SIZE, currentTableSize - readRouteSession.currentSendIndex);												routeTableResponse.response.fragment = readRouteSession.currentSendFragment;						routeTableResponse.response.fragmentTotal = readRouteSession.totalSendExpected;						routeTableResponse.response.length = readRouteSession.currentSendFrameSize;												OM_ProccessResponseWithBodyOperation(&routeTableResponse.header,&readRouteSession.readBuffer[readRouteSession.currentSendIndex], readRouteSession.currentSendFrameSize);					}else					{						//Finish						readRouteSession.sendingState = false;					}				}else				{					//Something wrong at server size. Abort current session					readRouteSession.sendingState = false;				}			}else			{				readRouteSession.sendingState = false;				//TODO: SEND OR LOG ERROR (FRAGMENT OR FRAGMENT TOTAL NOT EXPECTED)			}		}else		{			//TODO: SEND OR LOG ERROR (NOT SENDING)		}	}else if(operation_header->opCode == RouteTableReadResponse)	{		//TODO: SEND NOTIFICATION	}				}
开发者ID:Aginorty,项目名称:wireless-network,代码行数:79,


示例25: snprintf

static void *mmap_alloc(size_t bytes){    char *file_name = NULL;    int fd = 0;    char *directory = NULL;    const char basename[] = "hugepagefile.SOS";    int size;    void *requested_base =         (void*) (((unsigned long) shmem_internal_data_base +                   shmem_internal_data_length + 2 * ONEGIG) & ~(ONEGIG - 1));    void *ret;    if (shmem_internal_heap_use_huge_pages) {        /*         * check what /proc/mounts has for explicit huge page support         */        if(find_hugepage_dir(shmem_internal_heap_huge_page_size, &directory) == 0) {            size = snprintf(NULL, 0, "%s/%s.%d", directory, basename, getpid());            if (size < 0) {                RAISE_WARN_STR("snprint returned error, cannot use huge pages");            } else {                file_name = malloc(size + 1);                if (file_name) {                    sprintf(file_name, "%s/%s.%d", directory, basename, getpid());                    fd = open(file_name, O_CREAT | O_RDWR, 0755);                    if (fd < 0) {                        RAISE_WARN_STR("file open failed, cannot use huge pages");                        fd = 0;                    } else {                        /* have to round up                           by the pagesize being used */                        bytes = CEILING(bytes, shmem_internal_heap_huge_page_size);                    }                }            }        }    }    ret = mmap(requested_base,               bytes,               PROT_READ | PROT_WRITE,               MAP_ANON | MAP_PRIVATE,               fd,               0);    if (ret == MAP_FAILED) {        RAISE_WARN_STR("mmap for symmetric heap failed");        ret = NULL;    }    if (fd) {        unlink(file_name);        close(fd);    }    if (directory) {        free(directory);    }    if (file_name) {        free(file_name);    }    return ret;}
开发者ID:jpdoyle,项目名称:SOS,代码行数:66,



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


C++ CELL函数代码示例
C++ CEIL函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。