本文整理汇总了C++中CEIL函数的典型用法代码示例。如果您正苦于以下问题:C++ CEIL函数的具体用法?C++ CEIL怎么用?C++ CEIL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CEIL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ep2_mul_fix_yaowi
void ep2_mul_fix_yaowi(ep2_t r, ep2_t *t, bn_t k) {
int i, j, l;
ep2_t a;
uint8_t win[CEIL(2 * FP_BITS, EP_DEPTH)];
ep2_null(a);
TRY {
ep2_new(a);
ep2_set_infty(r);
ep2_set_infty(a);
l = CEIL(2 * FP_BITS, EP_DEPTH);
bn_rec_win(win, &l, k, EP_DEPTH);
for (j = (1 << EP_DEPTH) - 1; j >= 1; j--) {
for (i = 0; i < l; i++) {
if (win[i] == j) {
ep2_add(a, a, t[i]);
}
}
ep2_add(r, r, a);
}
ep2_norm(r, r);
}
CATCH_ANY {
THROW(ERR_CAUGHT);
}
FINALLY {
ep2_free(a);
}
}
示例2: jgfs_enlarge
bool jgfs_enlarge(struct jgfs_dir_ent *dir_ent, uint32_t new_size) {
uint32_t clust_size = jgfs_clust_size();
if (new_size <= dir_ent->size) {
errx(1, "jgfs_enlarge: new_size is not larger");
}
bool nospc = false;
uint16_t clust_before = CEIL(dir_ent->size, clust_size),
clust_after = CEIL(new_size, clust_size);
fat_ent_t new_addr;
if (clust_before != clust_after) {
/* special case for zero-size files */
if (dir_ent->size == 0) {
if (jgfs_fat_find(FAT_FREE, &new_addr)) {
dir_ent->begin = new_addr;
jgfs_fat_write(new_addr, FAT_EOF);
clust_before = 1;
} else {
return false;
}
}
fat_ent_t this = dir_ent->begin, next;
for (uint16_t i = 1; i < clust_after; ++i) {
next = jgfs_fat_read(this);
/* this means the filesystem is inconsistent */
if (this == FAT_EOF && i < clust_before) {
warnx("jgfs_enlarge: found premature FAT_EOF in clust chain");
clust_before = i;
}
if (i >= clust_before) {
if (jgfs_fat_find(FAT_FREE, &new_addr)) {
jgfs_fat_write(this, new_addr);
jgfs_fat_write(new_addr, FAT_EOF);
this = new_addr;
} else {
clust_after = i - 1;
new_size = clust_after * clust_size;
nospc = true;
break;
}
} else {
this = next;
}
}
}
jgfs_zero_span(dir_ent, dir_ent->size, new_size - dir_ent->size);
dir_ent->size = new_size;
return !nospc;
}
示例3: _fill_polygon_gray8
static int
_fill_polygon_gray8(uint8_t *img,
int npoints, Edge *e, uint8_t intensity,
int w, int h, int rowstride)
{
int i, j;
float *xx;
int ymin, ymax;
float y;
if (npoints <= 0) return 0;
/* Find upper and lower polygon boundary (within image) */
ymin = e[0].ymin;
ymax = e[0].ymax;
for (i = 1; i < npoints; i++) {
if (e[i].ymin < ymin) ymin = e[i].ymin;
if (e[i].ymax > ymax) ymax = e[i].ymax;
}
if (ymin < 0) ymin = 0;
if (ymax >= h) ymax = h-1;
/* Process polygon edges */
xx = malloc(npoints * sizeof(float));
if (!xx) return -1;
for (;ymin <= ymax; ymin++) {
y = ymin+0.5F;
for (i = j = 0; i < npoints; i++) {
if (y >= e[i].ymin && y <= e[i].ymax) {
if (e[i].d == 0)
draw_hline_gray8(img, e[i].xmin, ymin, e[i].xmax,
intensity, w, h, rowstride);
else
xx[j++] = (y-e[i].y0) * e[i].dx + e[i].x0;
}
}
if (j == 2) {
if (xx[0] < xx[1])
draw_hline_gray8(img, CEIL(xx[0]-0.5), ymin, FLOOR(xx[1]+0.5),
intensity, w, h, rowstride);
else
draw_hline_gray8(img, CEIL(xx[1]-0.5), ymin, FLOOR(xx[0]+0.5),
intensity, w, h, rowstride);
} else {
qsort(xx, j, sizeof(float), x_cmp);
for (i = 0; i < j-1 ; i += 2)
draw_hline_gray8(img, CEIL(xx[i]-0.5), ymin, FLOOR(xx[i+1]+0.5),
intensity, w, h, rowstride);
}
}
free(xx);
return 0;
}
示例4: rfbScaledCorrection
/* So, all of the encodings point to the ->screen->frameBuffer,
* We need to change this!
*/
void rfbScaledCorrection(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int *x, int *y, int *w, int *h, char *function)
{
double x1,y1,w1,h1, x2, y2, w2, h2;
double scaleW = ((double) to->width) / ((double) from->width);
double scaleH = ((double) to->height) / ((double) from->height);
/*
* rfbLog("rfbScaledCorrection(%p -> %p, %dx%d->%dx%d (%dXx%dY-%dWx%dH)\n",
* from, to, from->width, from->height, to->width, to->height, *x, *y, *w, *h);
*/
/* If it's the original framebuffer... */
if (from==to) return;
x1 = ((double) *x) * scaleW;
y1 = ((double) *y) * scaleH;
w1 = ((double) *w) * scaleW;
h1 = ((double) *h) * scaleH;
/*cast from double to int is same as "*x = floor(x1);" */
x2 = FLOOR(x1);
y2 = FLOOR(y1);
/* include into W and H the jitter of scaling X and Y */
w2 = CEIL(w1 + ( x1 - x2 ));
h2 = CEIL(h1 + ( y1 - y2 ));
/*
* rfbLog("%s (%dXx%dY-%dWx%dH -> %fXx%fY-%fWx%fH) {%dWx%dH -> %dWx%dH}\n",
* function, *x, *y, *w, *h, x2, y2, w2, h2,
* from->width, from->height, to->width, to->height);
*/
/* simulate ceil() without math library */
*x = (int)x2;
*y = (int)y2;
*w = (int)w2;
*h = (int)h2;
/* Small changes for a thumbnail may be scaled to zero */
if (*w==0) (*w)++;
if (*h==0) (*h)++;
/* scaling from small to big may overstep the size a bit */
if (*x+*w > to->width) *w=to->width - *x;
if (*y+*h > to->height) *h=to->height - *y;
}
示例5: str9xpec_set_instr
int str9xpec_set_instr(jtag_tap_t *tap, u32 new_instr, tap_state_t end_state)
{
if( tap == NULL ){
return ERROR_TARGET_INVALID;
}
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr)
{
scan_field_t field;
field.tap = tap;
field.num_bits = tap->ir_length;
field.out_value = calloc(CEIL(field.num_bits, 8), 1);
buf_set_u32(field.out_value, 0, field.num_bits, new_instr);
field.out_mask = NULL;
field.in_value = NULL;
field.in_check_value = NULL;
field.in_check_mask = NULL;
field.in_handler = NULL;
field.in_handler_priv = NULL;
jtag_add_ir_scan(1, &field, end_state);
free(field.out_value);
}
return ERROR_OK;
}
示例6: footprint_blob
/* Footprint of a blob ----------------------------------------------------- */
void footprint_blob(
ImageOver &blobprint, // blob foot_print table
const struct blobtype &blob, // blob description
int istep, // number of foot-print samples per one sample
// on projection plane in u,v directions
int normalise) // set to 1 if you want normalise. Usually
// you may omit it and no normalisation is performed
{
// Resize output image and redefine the origin of it
int footmax = CEIL(blob.radius);
blobprint.init(-footmax, footmax, istep, -footmax, footmax, istep);
// Run for Imge class indexes
for (int i = STARTINGY(blobprint()); i <= FINISHINGY(blobprint()); i++)
for (int j = STARTINGX(blobprint()); j <= FINISHINGX(blobprint()); j++)
{
// Compute oversampled index and blob value
double vi, ui;
IMG2OVER(blobprint, i, j, vi, ui);
double r = sqrt(vi * vi + ui * ui);
IMGPIXEL(blobprint, i, j) = blob_proj(r, blob);
}
// Adjust the footprint structure
if (normalise)
blobprint() /= blobprint().sum();
}
示例7: get_chunks_to_complete_relative_chunk
//Given a chunk, calculates the number of the chunks needed to complete a relative chunk, forwards.
static inline size_t get_chunks_to_complete_relative_chunk(size_t chunk, size_t chunk_size, size_t other_chunk_size)
{
uint64_t delta = get_next_relative_chunk_position(chunk, chunk_size, other_chunk_size) - get_chunk_position(chunk, chunk_size);
if (delta)
return CEIL(delta, chunk_size);
return 0;
}
示例8: i_sceiling
integer i_sceiling(real *x)
#endif
{
#define CEIL(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
return (integer) CEIL(*x);
}
示例9: cp_ecss_sig
int cp_ecss_sig(bn_t e, bn_t s, uint8_t *msg, int len, bn_t d) {
bn_t n, k, x, r;
ec_t p;
uint8_t hash[MD_LEN];
uint8_t m[len + FC_BYTES];
int result = STS_OK;
bn_null(n);
bn_null(k);
bn_null(x);
bn_null(r);
ec_null(p);
TRY {
bn_new(n);
bn_new(k);
bn_new(x);
bn_new(r);
ec_new(p);
ec_curve_get_ord(n);
do {
bn_rand_mod(k, n);
ec_mul_gen(p, k);
ec_get_x(x, p);
bn_mod(r, x, n);
} while (bn_is_zero(r));
memcpy(m, msg, len);
bn_write_bin(m + len, FC_BYTES, r);
md_map(hash, m, len + FC_BYTES);
if (8 * MD_LEN > bn_bits(n)) {
len = CEIL(bn_bits(n), 8);
bn_read_bin(e, hash, len);
bn_rsh(e, e, 8 * MD_LEN - bn_bits(n));
} else {
bn_read_bin(e, hash, MD_LEN);
}
bn_mod(e, e, n);
bn_mul(s, d, e);
bn_mod(s, s, n);
bn_sub(s, n, s);
bn_add(s, s, k);
bn_mod(s, s, n);
}
CATCH_ANY {
result = STS_ERR;
}
FINALLY {
bn_free(n);
bn_free(k);
bn_free(x);
bn_free(r);
ec_free(p);
}
return result;
}
示例10: create_hashtable
struct hashtable * create_hashtable(unsigned int minsize,
uint32_t (*hashfn) (String key),
boolean (*eqfn) (const String str1, const String str2))
{
struct hashtable *h;
unsigned int pindex, size = primes[0];
/* Check requested hashtable isn't too large */
if (minsize > MAX_HASH_TABLE_SIZE) return NULL;
/* Enforce size as prime */
for (pindex=0; pindex < prime_table_length; pindex++) {
if (primes[pindex] >= minsize) { size = primes[pindex]; break; }
}
h = (struct hashtable *)EXIP_MALLOC(sizeof(struct hashtable));
if (NULL == h) return NULL; /*oom*/
h->table = (struct entry **)EXIP_MALLOC(sizeof(struct entry*) * size);
if (NULL == h->table) { EXIP_MFREE(h); return NULL; } /*oom*/
memset(h->table, 0, size * sizeof(struct entry *));
h->tablelength = size;
h->primeindex = pindex;
h->entrycount = 0;
h->hashfn = hashfn;
h->eqfn = eqfn;
h->loadlimit = CEIL(size * max_load_factor);
return h;
}
示例11: exec_viewtiles
static void exec_viewtiles(const char* args, context_t* ctx, debug_t* dbg)
{
(void)args;
(void)ctx;
if (!dbg->show_tiles) {
dbg->window = window_create(
"Tiles",
(DBG_TILES_PER_ROW) * (TILE_WIDTH + 1),
CEIL(MAX_TILES, DBG_TILES_PER_ROW) * (TILE_HEIGHT + 1)
);
if (dbg->window == NULL) {
printf("Failed to create window\n");
return;
}
} else {
window_free(dbg->window);
dbg->window = NULL;
}
dbg->show_tiles = !dbg->show_tiles;
printf("Toggling tile view.\n");
}
示例12: CEIL
void Column::Resize(size_t num) {
num_tuples_ = num;
const size_t new_num_blocks = CEIL(num, kNumTuplesPerBlock);
const size_t old_num_blocks = blocks_.size();
if (new_num_blocks > old_num_blocks) { // need to add blocks
// fill up the last block
blocks_[old_num_blocks - 1]->Resize(kNumTuplesPerBlock);
// append new blocks
for (size_t bid = old_num_blocks; bid < new_num_blocks; bid++) {
ColumnBlock* new_block = CreateNewBlock();
new_block->Resize(kNumTuplesPerBlock);
blocks_.push_back(new_block);
}
} else if (new_num_blocks < old_num_blocks) { // need to remove blocks
for (size_t bid = old_num_blocks - 1; bid > new_num_blocks; bid--) {
delete blocks_.back();
blocks_.pop_back();
}
}
// now the number of block is desired
// correct the size of the last block
size_t num_tuples_last_block = num % kNumTuplesPerBlock;
if (0 < num_tuples_last_block) {
blocks_.back()->Resize(num_tuples_last_block);
}
assert(blocks_.size() == new_num_blocks);
}
示例13: jg_getattr
int jg_getattr(const char *path, struct stat *buf) {
struct jgfs_dir_clust *parent;
struct jgfs_dir_ent *child;
int rtn;
if ((rtn = jgfs_lookup(path, &parent, &child)) != 0) {
return rtn;
}
buf->st_nlink = 1;
buf->st_uid = 0;
buf->st_gid = 0;
buf->st_size = child->size;
buf->st_blocks = CEIL(child->size, jgfs_clust_size());
buf->st_atime = buf->st_ctime = buf->st_mtime = child->mtime;
if (child->type == TYPE_FILE) {
buf->st_mode = 0644 | S_IFREG;
} else if (child->type == TYPE_DIR) {
buf->st_mode = 0755 | S_IFDIR;
} else if (child->type == TYPE_SYMLINK) {
buf->st_mode = 0777 | S_IFLNK;
} else {
errx(1, "jg_getattr: unknown type 0x%x", child->type);
}
return 0;
}
示例14: switch
void FORTE_F_CEIL::executeEvent(int pa_nEIID){
switch(pa_nEIID){
case scm_nEventREQID:
OUT() = CEIL(X());
sendOutputEvent(scm_nEventCNFID);
break;
}
}
示例15: access_bank
void access_bank(uint64_t gpu_mask, int shift, uint64_t iter){
int oft = 0;
if(gpu_mask > 0){
g_mem_size += gpu_mask;
oft += gpu_mask / 4;
}
if(shift >= 0){
g_mem_size += (uint64_t)1 << shift;
oft += ((uint64_t)1 << shift) / 4;
}
g_mem_size += farest_dist;
g_mem_size = CEIL(g_mem_size, min_interval);
/* alloc memory. align to a page boundary */
int fd = open("/dev/mem", O_RDWR | O_SYNC);
void *addr = (void *) 0x1000000080000000;
int *memchunk = NULL;
if (fd < 0) {
perror("Open failed");
exit(1);
}
memchunk = mmap(0, g_mem_size,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd, (off_t)addr);
if (memchunk == MAP_FAILED) {
perror("failed to alloc");
exit(1);
}
list = &memchunk[oft];
next = 0;
struct timespec start, end;
clock_gettime(CLOCK_REALTIME, &start);
/* access banks */
uint64_t naccess = run(iter);
clock_gettime(CLOCK_REALTIME, &end);
uint64_t nsdiff = get_elapsed(&start, &end);
//printf("bandwidth %.2f MB/s\n", 64.0*1000.0*(double)naccess/(double)nsdiff);
if(shift >= 0)
bandwidth[shift] = 64.0 * 1000.0 * (double)naccess/(double)nsdiff;
else
bandwidth[MAX_SHIFT_NUM - 1] = 64.0 * 1000.0 * (double)naccess/(double)nsdiff;
munmap(memchunk, g_mem_size);
close(fd);
}