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


C++ CEILING函数代码示例

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


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

示例1: Destroy_LU

/*! \brief Destroy distributed L & U matrices. */
void
Destroy_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,代码来源:util.c

示例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,代码来源:dmemory.c

示例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,代码来源:flex_test.c

示例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,代码来源:vmciKernelIf.c

示例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,代码来源:ultralcd_DOGM.cpp

示例6: win_occpuants_cols

int
win_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,代码来源:window.c

示例7: win_roster_cols

int
win_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,代码来源:window.c

示例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,代码来源:lte_segmentation_func.c

示例9: check_ablk

void
check_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,代码来源:coalesce.c

示例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,代码来源:gnix_rma.c

示例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,代码来源:flex.c

示例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,代码来源:flex.c

示例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,代码来源:DVDRipper.cpp

示例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,代码来源:flex.c

示例15: VMCI_FreeQueue

void
VMCI_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,代码来源:vmciKernelIf.c


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