这篇教程C++ GET函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GET函数的典型用法代码示例。如果您正苦于以下问题:C++ GET函数的具体用法?C++ GET怎么用?C++ GET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GET函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: fFUNCTION_PTR Parser::Parse_DeclareFunction(int *token_id, const char *fn_name, bool is_local){ FUNCTION_PTR ptr = (FUNCTION_PTR)POV_MALLOC(sizeof(FUNCTION), "Function ID"); ExprNode *expression = NULL; FunctionCode function; // default type is float function *token_id = FUNCT_ID_TOKEN; FNCode f(this, &function, is_local, fn_name); f.Parameter(); Parse_Begin(); Get_Token(); if(Token.Token_Id == INTERNAL_TOKEN) { GET(LEFT_PAREN_TOKEN); Get_Token(); if(Token.Function_Id != FLOAT_TOKEN) Expectation_Error("internal function identifier"); expression = FNSyntax_GetTrapExpression((unsigned int)(Token.Token_Float)); function.flags = FN_INLINE_FLAG; GET(RIGHT_PAREN_TOKEN); } else if(Token.Token_Id == TRANSFORM_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for transform functions are not allowed."); expression = FNSyntax_GetTrapExpression(1); // 1 refers to POVFPU_TrapSTable[1] = f_transform [trf] function.private_copy_method = (FNCODE_PRIVATE_COPY_METHOD)Copy_Transform; function.private_destroy_method = (FNCODE_PRIVATE_DESTROY_METHOD)Destroy_Transform; function.private_data = reinterpret_cast<void *>(Parse_Transform_Block()); function.return_size = 3; // returns a 3d vector!!! // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } else if(Token.Token_Id == SPLINE_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for spline functions are not allowed."); Experimental_Flag |= EF_SPLINE; expression = FNSyntax_GetTrapExpression(2); // 2 refers to POVFPU_TrapSTable[2] = f_spline [trf] function.private_copy_method = (FNCODE_PRIVATE_COPY_METHOD)Copy_Spline; function.private_destroy_method = (FNCODE_PRIVATE_DESTROY_METHOD)Destroy_Spline; Parse_Begin(); function.private_data = reinterpret_cast<void *>(Parse_Spline()); Parse_End(); function.return_size = (reinterpret_cast<SPLINE *>(function.private_data))->Terms; // returns a 2d, 3d, 4d or 5d vector!!! // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } else if(Token.Token_Id == PIGMENT_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for pigment functions are not allowed."); expression = FNSyntax_GetTrapExpression(0); // 0 refers to POVFPU_TrapSTable[0] = f_pigment [trf] function.private_copy_method = (FNCODE_PRIVATE_COPY_METHOD)Copy_Pigment; function.private_destroy_method = (FNCODE_PRIVATE_DESTROY_METHOD)Destroy_Pigment; Parse_Begin(); function.private_data = reinterpret_cast<void *>(Create_Pigment()); Parse_Pigment(reinterpret_cast<PIGMENT **>(&function.private_data)); Parse_End(); Post_Pigment(reinterpret_cast<PIGMENT *>(function.private_data)); function.return_size = 5; // returns a color!!! // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } else if(Token.Token_Id == PATTERN_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for pattern functions are not allowed."); expression = FNSyntax_GetTrapExpression(77); // 77 refers to POVFPU_TrapTable[77] = f_pattern [trf] function.private_copy_method = (FNCODE_PRIVATE_COPY_METHOD)Copy_Pigment; function.private_destroy_method = (FNCODE_PRIVATE_DESTROY_METHOD)Destroy_Pigment; Parse_Begin(); function.private_data = reinterpret_cast<void *>(Create_Pigment()); // Yes, this is a pigment! [trf] Parse_PatternFunction(reinterpret_cast<TPATTERN *>(function.private_data));//.........这里部分代码省略.........
开发者ID:Degot,项目名称:povray,代码行数:101,
示例2: suni_hzstatic void suni_hz(unsigned long from_timer){ struct suni_priv *walk; struct atm_dev *dev; struct k_sonet_stats *stats; for (walk = sunis; walk; walk = walk->next) { dev = walk->dev; stats = &walk->sonet_stats; PUT(0,MRI); /* latch counters */ udelay(1); ADD_LIMITED(section_bip,(GET(RSOP_SBL) & 0xff) | ((GET(RSOP_SBM) & 0xff) << 8)); ADD_LIMITED(line_bip,(GET(RLOP_LBL) & 0xff) | ((GET(RLOP_LB) & 0xff) << 8) | ((GET(RLOP_LBM) & 0xf) << 16)); ADD_LIMITED(path_bip,(GET(RPOP_PBL) & 0xff) | ((GET(RPOP_PBM) & 0xff) << 8)); ADD_LIMITED(line_febe,(GET(RLOP_LFL) & 0xff) | ((GET(RLOP_LF) & 0xff) << 8) | ((GET(RLOP_LFM) & 0xf) << 16)); ADD_LIMITED(path_febe,(GET(RPOP_PFL) & 0xff) | ((GET(RPOP_PFM) & 0xff) << 8)); ADD_LIMITED(corr_hcs,GET(RACP_CHEC) & 0xff); ADD_LIMITED(uncorr_hcs,GET(RACP_UHEC) & 0xff); ADD_LIMITED(rx_cells,(GET(RACP_RCCL) & 0xff) | ((GET(RACP_RCC) & 0xff) << 8) | ((GET(RACP_RCCM) & 7) << 16)); ADD_LIMITED(tx_cells,(GET(TACP_TCCL) & 0xff) | ((GET(TACP_TCC) & 0xff) << 8) | ((GET(TACP_TCCM) & 7) << 16)); } if (from_timer) mod_timer(&poll_timer,jiffies+HZ);}
开发者ID:PennPanda,项目名称:linux-repo,代码行数:34,
示例3: HalfSizestatic int HalfSize(GLint components, GLint width, GLint height, const unsigned char *data, unsigned char *d, int filter) { int x, y, c; int line = width*components; if (width > 1 && height > 1) { if (filter) for (y = 0; y < height; y += 2) { for (x = 0; x < width; x += 2) { for (c = 0; c < components; c++) { *d++ = (GET(0)+GET(components)+GET(line)+GET(line+components)) / 4; data++; } data += components; } data += line; } else for (y = 0; y < height; y += 2) { for (x = 0; x < width; x += 2) { for (c = 0; c < components; c++) { *d++ = GET(0); data++; } data += components; } data += line; } } else if (width > 1 && height == 1) { if (filter) for (y = 0; y < height; y += 1) { for (x = 0; x < width; x += 2) { for (c = 0; c < components; c++) { *d++ = (GET(0)+GET(components)) / 2; data++; } data += components; } } else for (y = 0; y < height; y += 1) { for (x = 0; x < width; x += 2) { for (c = 0; c < components; c++) { *d++ = GET(0); data++; } data += components; } } } else if (width == 1 && height > 1) { if (filter) for (y = 0; y < height; y += 2) { for (x = 0; x < width; x += 1) { for (c = 0; c < components; c++) { *d++ = (GET(0)+GET(line)) / 2; data++; } } data += line; } else for (y = 0; y < height; y += 2) { for (x = 0; x < width; x += 1) { for (c = 0; c < components; c++) { *d++ = GET(0); data++; } } data += line; } } else { return 0; } return 1;}
开发者ID:schell,项目名称:schells.tmbundle,代码行数:78,
示例4: do_scrub_chars//.........这里部分代码省略......... fromend = from + saved_input_len; } else { fromlen = (*get) (input_buffer, sizeof input_buffer); if (fromlen == 0) return 0; from = input_buffer; fromend = from + fromlen; } while (1) { /* The cases in this switch end with continue, in order to branch back to the top of this while loop and generate the next output character in the appropriate state. */ switch (state) { case -1: ch = *out_string++; if (*out_string == '/0') { state = old_state; old_state = 3; } PUT (ch); continue; case -2: for (;;) { do { ch = GET (); if (ch == EOF) { as_warn (_("end of file in comment")); goto fromeof; } if (ch == '/n') PUT ('/n'); } while (ch != '*'); while ((ch = GET ()) == '*') ; if (ch == EOF) { as_warn (_("end of file in comment")); goto fromeof; } if (ch == '/') break; UNGET (ch); } state = old_state; UNGET (' '); continue; case 4:
开发者ID:DayOperatingSystem,项目名称:Binutils,代码行数:67,
示例5: _icv_iconv/* * Actual conversion; called from iconv() */size_t_icv_iconv(struct _icv_state *st, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft){ int cset, stat; unsigned char *op, ic, offset; char *ip; size_t ileft, oleft; size_t retval; cset = st->_st_cset; stat = st->_st_stat; if ((inbuf == 0) || (*inbuf == 0)) { cset = CS_0; stat = ST_INIT; op = (unsigned char *)*outbuf; oleft = *outbytesleft; retval = 0; goto ret2; } ip = *inbuf; op = (unsigned char *)*outbuf; ileft = *inbytesleft; oleft = *outbytesleft; offset = 0; /* Everything down to here was taken unchanged from @(#)ISO-2022-JP%SJIS. ======================================================================= * * Main loop; basically 1 loop per 1 input byte */ while (ileft > 0) { GET(ic); /* If the char is one of the following [ / ] { | } then convert it to its corresponding value. In all other cases if the char is greater than octal /178 ( ie a high bit char) convert it to an underscore (_), as it has no mapping to 7 bit ASCII. Otrherwise the char is the same in both cose sets. */ ic=__ib2_to_wi2[ic]; PUT(ic); /* Put the converted character into the output buffer, and decrement the count of chars left in both the in and out buffers. If we have no space left in the out buffer, but we have no reached the end of the input buffer. We return what we have, and set the errno (Error) to E2BIG. */ if ((oleft < 1) && (ileft > 0)) { errno = E2BIG; retval = ERR_RETURN; goto ret; } }/* We only get here if the end of the in buffer has been reached, we therefore return thevalue 0 to denote that we have sucesfully converted the inbuffer.*/ retval = ileft;/* Taken unchanged from @(#)ISO-2022-JP%SJIS. */ret: st->_st_cset = cset; st->_st_stat = stat; *inbuf = ip; *inbytesleft = ileft;ret2: *outbuf = (char *)op; *outbytesleft = oleft; return (retval);}
开发者ID:alhazred,项目名称:illumos-extra,代码行数:87,
示例6: set_start_bitsstatic intset_start_bits(const uschar *code, uschar *start_bits, BOOL caseless, BOOL utf8, compile_data *cd){register int c;int yield = SSB_DONE;int table_limit = utf8? 16:32;#if 0/* ========================================================================= *//* The following comment and code was inserted in January 1999. In May 2006,when it was observed to cause compiler warnings about unused values, I took itout again. If anybody is still using OS/2, they will have to put it backmanually. *//* This next statement and the later reference to dummy are here in order totrick the optimizer of the IBM C compiler for OS/2 into generating correctcode. Apparently IBM isn't going to fix the problem, and we would rather notdisable optimization (in this module it actually makes a big difference, andthe pcre module can use all the optimization it can get). */volatile int dummy;/* ========================================================================= */#endifdo { const uschar *tcode = code + (((int)*code == OP_CBRA)? 3:1) + LINK_SIZE; BOOL try_next = TRUE; while (try_next) /* Loop for items in this branch */ { int rc; switch(*tcode) { /* Fail if we reach something we don't understand */ default: return SSB_FAIL; /* If we hit a bracket or a positive lookahead assertion, recurse to set bits from within the subpattern. If it can't find anything, we have to give up. If it finds some mandatory character(s), we are done for this branch. Otherwise, carry on scanning after the subpattern. */ case OP_BRA: case OP_SBRA: case OP_CBRA: case OP_SCBRA: case OP_ONCE: case OP_ASSERT: rc = set_start_bits(tcode, start_bits, caseless, utf8, cd); if (rc == SSB_FAIL) return SSB_FAIL; if (rc == SSB_DONE) try_next = FALSE; else { do tcode += GET(tcode, 1); while (*tcode == OP_ALT); tcode += 1 + LINK_SIZE; } break; /* If we hit ALT or KET, it means we haven't found anything mandatory in this branch, though we might have found something optional. For ALT, we continue with the next alternative, but we have to arrange that the final result from subpattern is SSB_CONTINUE rather than SSB_DONE. For KET, return SSB_CONTINUE: if this is the top level, that indicates failure, but after a nested subpattern, it causes scanning to continue. */ case OP_ALT: yield = SSB_CONTINUE; try_next = FALSE; break; case OP_KET: case OP_KETRMAX: case OP_KETRMIN: return SSB_CONTINUE; /* Skip over callout */ case OP_CALLOUT: tcode += 2 + 2*LINK_SIZE; break; /* Skip over lookbehind and negative lookahead assertions */ case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: do tcode += GET(tcode, 1); while (*tcode == OP_ALT); tcode += 1 + LINK_SIZE; break; /* Skip over an option setting, changing the caseless flag */ case OP_OPT: caseless = (tcode[1] & PCRE_CASELESS) != 0; tcode += 2; break; /* BRAZERO does the bracket, but carries on. *///.........这里部分代码省略.........
开发者ID:Kirozen,项目名称:winmerge-v2,代码行数:101,
示例7: set_start_bits//.........这里部分代码省略......... if (c > 0xff) SET_BIT(0xff); else SET_BIT(c); } } try_next = FALSE; break; /* We can ignore word boundary tests. */ case OP_WORD_BOUNDARY: case OP_NOT_WORD_BOUNDARY: tcode++; break; /* If we hit a bracket or a positive lookahead assertion, recurse to set bits from within the subpattern. If it can't find anything, we have to give up. If it finds some mandatory character(s), we are done for this branch. Otherwise, carry on scanning after the subpattern. */ case OP_BRA: case OP_SBRA: case OP_CBRA: case OP_SCBRA: case OP_BRAPOS: case OP_SBRAPOS: case OP_CBRAPOS: case OP_SCBRAPOS: case OP_ONCE: case OP_ONCE_NC: case OP_ASSERT: rc = set_start_bits(tcode, start_bits, utf, cd); if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc; if (rc == SSB_DONE) try_next = FALSE; else { do tcode += GET(tcode, 1); while (*tcode == OP_ALT); tcode += 1 + LINK_SIZE; } break; /* If we hit ALT or KET, it means we haven't found anything mandatory in this branch, though we might have found something optional. For ALT, we continue with the next alternative, but we have to arrange that the final result from subpattern is SSB_CONTINUE rather than SSB_DONE. For KET, return SSB_CONTINUE: if this is the top level, that indicates failure, but after a nested subpattern, it causes scanning to continue. */ case OP_ALT: yield = SSB_CONTINUE; try_next = FALSE; break; case OP_KET: case OP_KETRMAX: case OP_KETRMIN: case OP_KETRPOS: return SSB_CONTINUE; /* Skip over callout */ case OP_CALLOUT: tcode += 2 + 2*LINK_SIZE; break; /* Skip over lookbehind and negative lookahead assertions */ case OP_ASSERT_NOT: case OP_ASSERTBACK:
开发者ID:7segments,项目名称:mongo-1,代码行数:67,
示例8: GET_ALLOCstatic inline int GET_ALLOC( void *p ) { return GET(p) & 0x1;}
开发者ID:CSUChico-CSCI540,项目名称:CSCI540-MallocLab,代码行数:3,
示例9: find_minlengthstatic intfind_minlength(const pcre2_real_code *re, PCRE2_SPTR code, PCRE2_SPTR startcode, BOOL utf, recurse_check *recurses, int *countptr, int *backref_cache){int length = -1;int prev_cap_recno = -1;int prev_cap_d = 0;int prev_recurse_recno = -1;int prev_recurse_d = 0;uint32_t once_fudge = 0;BOOL had_recurse = FALSE;BOOL dupcapused = (re->flags & PCRE2_DUPCAPUSED) != 0;recurse_check this_recurse;int branchlength = 0;PCRE2_UCHAR *cc = (PCRE2_UCHAR *)code + 1 + LINK_SIZE;/* If this is a "could be empty" group, its minimum length is 0. */if (*code >= OP_SBRA && *code <= OP_SCOND) return 0;/* Skip over capturing bracket number */if (*code == OP_CBRA || *code == OP_CBRAPOS) cc += IMM2_SIZE;/* A large and/or complex regex can take too long to process. */if ((*countptr)++ > 1000) return -1;/* Scan along the opcodes for this branch. If we get to the end of the branch,check the length against that of the other branches. If the accumulated lengthpasses 16-bits, stop. */for (;;) { int d, min, recno; PCRE2_UCHAR *cs, *ce; PCRE2_UCHAR op = *cc; if (branchlength >= UINT16_MAX) return UINT16_MAX; switch (op) { case OP_COND: case OP_SCOND: /* If there is only one branch in a condition, the implied branch has zero length, so we don't add anything. This covers the DEFINE "condition" automatically. If there are two branches we can treat it the same as any other non-capturing subpattern. */ cs = cc + GET(cc, 1); if (*cs != OP_ALT) { cc = cs + 1 + LINK_SIZE; break; } goto PROCESS_NON_CAPTURE; /* There's a special case of OP_ONCE, when it is wrapped round an OP_RECURSE. We'd like to process the latter at this level so that remembering the value works for repeated cases. So we do nothing, but set a fudge value to skip over the OP_KET after the recurse. */ case OP_ONCE: if (cc[1+LINK_SIZE] == OP_RECURSE && cc[2*(1+LINK_SIZE)] == OP_KET) { once_fudge = 1 + LINK_SIZE; cc += 1 + LINK_SIZE; break; } /* Fall through */ case OP_ONCE_NC: case OP_BRA: case OP_SBRA: case OP_BRAPOS: case OP_SBRAPOS: PROCESS_NON_CAPTURE: d = find_minlength(re, cc, startcode, utf, recurses, countptr, backref_cache); if (d < 0) return d; branchlength += d; do cc += GET(cc, 1); while (*cc == OP_ALT); cc += 1 + LINK_SIZE; break; /* To save time for repeated capturing subpatterns, we remember the length of the previous one. Unfortunately we can't do the same for the unnumbered ones above. Nor can we do this if (?| is present in the pattern because captures with the same number are not then identical. */ case OP_CBRA: case OP_SCBRA: case OP_CBRAPOS: case OP_SCBRAPOS: recno = (int)GET2(cc, 1+LINK_SIZE); if (dupcapused || recno != prev_cap_recno) { prev_cap_recno = recno;//.........这里部分代码省略.........
开发者ID:FateAce,项目名称:godot,代码行数:101,
示例10: add_to_free_list/********************************************************** * add_to_free_list * adds the free block to the free list **********************************************************/void add_to_free_list(void *bp){// printf("IN ADD_TO_FREE_LIST/n");// printf("adding free block %p/n",bp); //get the size of the free block size_t size = GET(HDRP(bp)); int i = get_segregated_index(size); //print_ptr(bp); if(segregated_list[i] == NULL) { //add the free block to the free list which is NULL segregated_list[i] = bp; //set the previous as 0 or (null/nothing) PUT(LOCATION_PREV_FREE_BLKP(bp),0); //set the next free block as 0 or (null/nothing) PUT(LOCATION_NEXT_FREE_BLKP(bp),0); } else { if(GET_SIZE(HDRP(segregated_list[i]))>GET_SIZE(HDRP(bp))){ if(GET_NEXT_FREE_BLK(segregated_list[i])!=0) { // print_seg(1);// void* sec_ptr = GET_NEXT_FREE_BLK(segregated_list[i]); PUT(LOCATION_NEXT_FREE_BLKP(bp),GET_NEXT_FREE_BLK(segregated_list[i])); PUT(GET_PREV_FREE_BLK(LOCATION_NEXT_FREE_BLKP(segregated_list[i])),bp); PUT(LOCATION_NEXT_FREE_BLKP(segregated_list[i]),bp); PUT(LOCATION_PREV_FREE_BLKP(bp),segregated_list[i]); //printf("test esfewfe/n"); // print_ptr(bp); // print_ptr(segregated_list[i]);//print_seg(1); }else{ //printf("test2/n"); //we only have 1 block in the list PUT(LOCATION_NEXT_FREE_BLKP(segregated_list[i]),bp); PUT(LOCATION_PREV_FREE_BLKP(bp),segregated_list[i]); PUT(LOCATION_PREV_FREE_BLKP(segregated_list[i]),0); PUT(LOCATION_NEXT_FREE_BLKP(bp),0); } }else { //Set the next block of the new head as the previous head PUT(LOCATION_NEXT_FREE_BLKP(bp),segregated_list[i]); //Set the previous block of the new head as NULL PUT(LOCATION_PREV_FREE_BLKP(bp), 0); //Set the previous block of the previous head to the new head PUT(LOCATION_PREV_FREE_BLKP(segregated_list[i]),bp); segregated_list[i] = bp; } }}
开发者ID:shareq2005,项目名称:Dynamic-Memory-Allocator,代码行数:69,
示例11: GET_SIZE//// Read the size and allocated fields from address p//static inline size_t GET_SIZE( void *p ) { return GET(p) & ~0x7;}
开发者ID:CSUChico-CSCI540,项目名称:CSCI540-MallocLab,代码行数:6,
示例12: test_main/* test routine */int test_main(int args, char ** argv) { int i,j; waypoint_vec_t wmap; region_map_t regs; INIT(wmap); INIT(regs); bool ret; for (i=0; i<7; i++) { PUSH_BACK(regs, regions[i]); } int self_refs = 0; bool r = makeWaypointTable(&wmap, ®s, NR_POINTS, points); iprintf ("Waypoint Table: /n"); iprintf (" /t "); for (i=0; i<SIZE(wmap); ++i) { iprintf("%6d ", i); } iprintf("/n"); for (i=0; i<SIZE(wmap); ++i) { iprintf ("%d: %5s/t (%7.1f,%7.1f) ", i, points[i].comment, GET(wmap, i).pos.x, GET(wmap, i).pos.y); for (j=0; j<SIZE(wmap); j++) { double dist = GET(wmap, i).distances[j]; char sep = ((j+1)%5) == 0? '|':' '; if (dist == INFINITY) { iprintf (" %c", sep); } else if (dist < 0.01) { if (i == j) { iprintf (" * %c", sep); self_refs++; } else { iprintf (" X %c", sep); } } else { iprintf ("%6.1f%c", GET(wmap, i).distances[j], sep); } } iprintf ("/n"); } iprintf("/nSelf References: %d/n", self_refs); iprintf ("Starting waypoint-waypoint tests./n"); for (i=0; i<SIZE(wmap); ++i) { int_vec_t path; INIT(path); ret = pathFind(&path, GET(wmap,0).pos, GET(wmap, i).pos, &wmap, ®s); iprintf ("RESULT: %d to %d: ", 0, i); for (j=0; j<SIZE(path); ++j) { iprintf ("%s (%d) ", points[GET(path,j)].comment, GET(path,j)); } iprintf ("/n"); } char startbuffer[128]; char endbuffer[128]; iprintf ("Interactive mode. Hit Ctrl-C to exit./n"); while (true) { iprintf ("/nStart: "); fgets(startbuffer, 127, stdin); startbuffer[127] = 0; iprintf ("End: "); fgets(endbuffer, 127, stdin); endbuffer[127] = 0; char *s, *e; if (strchr(startbuffer, '/n')) { (*strchr(startbuffer, '/n')) = 0; } if (strchr(endbuffer, '/n')) { (*strchr(endbuffer, '/n')) = 0; } s = startbuffer; while (isspace(*s)) s++; e = endbuffer; while (isspace(*e)) e++; int start=-1, end=-1; for (i=0; i<SIZE(wmap) && start < 0; ++i) { if (!strcasecmp(s, points[i].comment)) { start = i; } } for (i=0; i<SIZE(wmap) && end < 0; ++i) {//.........这里部分代码省略.........
开发者ID:lally,项目名称:ioquake,代码行数:101,
示例13: pathFindWorkstatic double pathFindWork(int_vec_t *destpath, int pos, int dest, path_bitmap_t seen, const waypoint_vec_t* wmap, const region_map_t* regs) { BEGIN_DEPTH; int_vec_t wpoints; INIT(wpoints); assert(pos >=0); assert(dest >=0); // already there. if (pos == dest) { END_DEPTH; return 0.0; } if (full_set(&seen)) { END_DEPTH; return INFINITY; } if (GET(*wmap,pos).distances[dest] != INFINITY) { PUSH_BACK(*destpath, dest); END_DEPTH; return GET(*wmap,pos).distances[dest]; } sortedWaypoints(&wpoints, pos, dest, wmap, regs); // remove those we've already seen. int j = 0; while (j < SIZE(wpoints)) { if (is_set(&seen, GET(wpoints,j))) { ERASE(wpoints, j); } else { ++j; } } if (SIZE(wpoints) == 0) { END_DEPTH; return INFINITY; } const int offset = SIZE(*destpath); int lowest_idx = -1; double lowest_value = INFINITY; int_vec_t tmp; INIT(tmp); COPY(tmp, *destpath); int i; for (i=0; i<SIZE(wpoints); ++i) { if (!is_set(&seen, GET(wpoints,i))) { double val; PUSH_BACK(tmp, GET(wpoints,i)); path_bitmap_t local_seen = seen; set(&local_seen, GET(wpoints,i)); val = pathFindWork(&tmp, GET(wpoints,i), dest, local_seen, wmap, regs) + GET(*wmap,pos).distances[GET(wpoints,i)]; if (lowest_value == INFINITY || (val != INFINITY && val < lowest_value)) { lowest_value = val; lowest_idx = GET(wpoints,i); COPY(*destpath, tmp); END_DEPTH; // with this return, it's an A* search. without, it's // a DFS. return val; } RESIZE(tmp, offset); } } // at the end, destpath has the minimum path we've seen so far, // and now we're returning our distance to the path we've appended on. END_DEPTH; return lowest_value; // + distance(wmap[pos].pos, wmap[lowest_idx].pos, regs);}
开发者ID:lally,项目名称:ioquake,代码行数:84,
示例14: pcre2_printintstatic voidpcre2_printint(pcre2_code *re, FILE *f, BOOL print_lengths){PCRE2_SPTR codestart, nametable, code;uint32_t nesize = re->name_entry_size;BOOL utf = (re->overall_options & PCRE2_UTF) != 0;nametable = (PCRE2_SPTR)((uint8_t *)re + sizeof(pcre2_real_code));code = codestart = nametable + re->name_count * re->name_entry_size;for(;;) { PCRE2_SPTR ccode; uint32_t c; int i; const char *flag = " "; unsigned int extra = 0; if (print_lengths) fprintf(f, "%3d ", (int)(code - codestart)); else fprintf(f, " "); switch(*code) {/* ========================================================================== */ /* These cases are never obeyed. This is a fudge that causes a compile- time error if the vectors OP_names or OP_lengths, which are indexed by opcode, are not the correct length. It seems to be the only way to do such a check at compile time, as the sizeof() operator does not work in the C preprocessor. */ case OP_TABLE_LENGTH: case OP_TABLE_LENGTH + ((sizeof(OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) && (sizeof(OP_lengths) == OP_TABLE_LENGTH)): break;/* ========================================================================== */ case OP_END: fprintf(f, " %s/n", OP_names[*code]); fprintf(f, "------------------------------------------------------------------/n"); return; case OP_CHAR: fprintf(f, " "); do { code++; code += 1 + print_char(f, code, utf); } while (*code == OP_CHAR); fprintf(f, "/n"); continue; case OP_CHARI: fprintf(f, " /i "); do { code++; code += 1 + print_char(f, code, utf); } while (*code == OP_CHARI); fprintf(f, "/n"); continue; case OP_CBRA: case OP_CBRAPOS: case OP_SCBRA: case OP_SCBRAPOS: if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); else fprintf(f, " "); fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE)); break; case OP_BRA: case OP_BRAPOS: case OP_SBRA: case OP_SBRAPOS: case OP_KETRMAX: case OP_KETRMIN: case OP_KETRPOS: case OP_ALT: case OP_KET: case OP_ASSERT: case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: case OP_ONCE: case OP_ONCE_NC: case OP_COND: case OP_SCOND: case OP_REVERSE: if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); else fprintf(f, " "); fprintf(f, "%s", OP_names[*code]); break; case OP_CLOSE: fprintf(f, " %s %d", OP_names[*code], GET2(code, 1));//.........这里部分代码省略.........
开发者ID:0xicl33n,项目名称:fish-shell,代码行数:101,
示例15: mdelem/* MDELEM: Process ELEMENT declaration.*/VOID mdelem(UNCH *tbuf) /* Work area for tokenization (tbuf). */{ UNCH *ranksuff = lbuf; /* Rank suffix. */ UNS dctype = 0; /* Declared content type (from dctab). */ UNCH fmin = 0; /* Minimization bit flags. */ int i; /* Loop counter. */ UNS u; /* Temporary variable. */ struct etd **mexgrp, **pexgrp; /* Ptr to model exceptions array. */ struct thdr *cmod, *cmodsv; /* Ptr to content model. */ UNCH *etdgi; /* GI of current etd (when going through group).*/ int minomitted = 0; /* Tag minimization parameters omitted. */ mdname = key[KELEMENT]; /* Identify declaration for messages. */ subdcl = NULL; /* No subject as yet. */ parmno = 0; /* No parameters as yet. */ mdessv = es; /* Save es level for entity nesting check. */ ranksuff[0] = 0; mexgrp = pexgrp = 0; /* PARAMETER 1: Element name or a group of them. */ parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); TRACEMD("1: element name or grp"); switch (pcbmd.action) { case NAS: nmgrp[0] = etddef(tbuf); nmgrp[1] = 0; break; case GRPS: parsegrp(nmgrp, &pcbgrnm, tbuf); break; default: mderr(121, (UNCH *)0, (UNCH *)0); return; } /* Save first GI for trace and error messages. */ if (nmgrp[0]) subdcl = nmgrp[0]->etdgi+1; /* PARAMETER 1A: Rank suffix (optional). */ parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); TRACEMD("1A: rank suffix"); switch (pcbmd.action) { case NUM: ustrcpy(ranksuff, tbuf); parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); default: break; } /* PARAMETER 2A: Start-tag minimization. */ TRACEMD("2A: start min"); switch (pcbmd.action) { case CDR: break; case NAS: if (!ustrcmp(tbuf+1, key[KO])) { if (OMITTAG==YES) SET(fmin, SMO); break; } /* fall through */ default: if (OMITTAG==NO) {minomitted=1; break;} mderr(129, tbuf+1, (UNCH *)0); return; } /* Must omit omitted end-tag minimization, if omitted start-tag minimization was omitted (because OMITTAG == NO). */ if (!minomitted) { /* PARAMETER 2B: End-tag minimization. */ parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); TRACEMD("2B: end min"); switch (pcbmd.action) { case NAS: if (ustrcmp(tbuf+1, key[KO])) {mderr(129, tbuf+1, (UNCH *)0); return;} if (OMITTAG==YES) SET(fmin, EMO); break; case CDR: SET(fmin, EMM); break; default: mderr(129, tbuf+1, (UNCH *)0); return; } /* PARAMETER 3: Declared content. */ parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); } TRACEMD("3: declared content"); switch (pcbmd.action) { case NAS: dctype = mapsrch(dctab, tbuf+1); if (!dctype) {mderr(24, tbuf+1, (UNCH *)0); return;} /* Eliminate incompatibilities among parameters. */ if (GET(fmin, SMO) && GET(dctype, MNONE+MCDATA+MRCDATA)) { mderr(58, (UNCH *)0, (UNCH *)0);//.........这里部分代码省略.........
开发者ID:johnBradley501,项目名称:TACT,代码行数:101,
示例16: set_start_bits//.........这里部分代码省略......... if (c > 0xff) SET_BIT(0xff); else SET_BIT(c); } } try_next = FALSE; break; /* We can ignore word boundary tests. */ case OP_WORD_BOUNDARY: case OP_NOT_WORD_BOUNDARY: tcode++; break; /* If we hit a bracket or a positive lookahead assertion, recurse to set bits from within the subpattern. If it can't find anything, we have to give up. If it finds some mandatory character(s), we are done for this branch. Otherwise, carry on scanning after the subpattern. */ case OP_BRA: case OP_SBRA: case OP_CBRA: case OP_SCBRA: case OP_BRAPOS: case OP_SBRAPOS: case OP_CBRAPOS: case OP_SCBRAPOS: case OP_ONCE: case OP_ONCE_NC: case OP_ASSERT: rc = set_start_bits(re, tcode, utf); if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc; if (rc == SSB_DONE) try_next = FALSE; else { do tcode += GET(tcode, 1); while (*tcode == OP_ALT); tcode += 1 + LINK_SIZE; } break; /* If we hit ALT or KET, it means we haven't found anything mandatory in this branch, though we might have found something optional. For ALT, we continue with the next alternative, but we have to arrange that the final result from subpattern is SSB_CONTINUE rather than SSB_DONE. For KET, return SSB_CONTINUE: if this is the top level, that indicates failure, but after a nested subpattern, it causes scanning to continue. */ case OP_ALT: yield = SSB_CONTINUE; try_next = FALSE; break; case OP_KET: case OP_KETRMAX: case OP_KETRMIN: case OP_KETRPOS: return SSB_CONTINUE; /* Skip over callout */ case OP_CALLOUT: tcode += PRIV(OP_lengths)[OP_CALLOUT]; break; case OP_CALLOUT_STR: tcode += GET(tcode, 1 + 2*LINK_SIZE); break;
开发者ID:FateAce,项目名称:godot,代码行数:66,
示例17: pnl_basis_eval_teststatic void pnl_basis_eval_test (){ PnlMat *X; PnlVect *V, *x, *t, *D, *alpha, *lower, *upper; PnlRng *rng; PnlBasis *basis; int j, deg, n; double t0, x0, tol; tol = 1E-8; deg=5; //total degree n=50; D=pnl_vect_create(5); x=pnl_vect_create(n); t=pnl_vect_create(n); t0=0.5; x0=2.5; rng = pnl_rng_create (PNL_RNG_MERSENNE); pnl_rng_sseed (rng, 0); /* * Random points where the function will be evaluted */ pnl_vect_rng_uni(x,n,-5,4,rng); pnl_vect_rng_uni(t,n,0,1,rng); basis = pnl_basis_create_from_degree (PNL_BASIS_HERMITIAN, deg, 2); alpha = pnl_vect_create (basis->nb_func); X = pnl_mat_create (n, 2); for(j=0;j<n;j++) { MLET (X, j, 0) = GET(t,j); MLET (X, j, 1) = GET(x,j); } V=pnl_vect_create(n); /* * Vector of values for the function to recover */ for(j=0;j<n;j++) { LET(V,j)=fonction_a_retrouver(GET(t,j),GET(x,j)); } pnl_basis_fit_ls (basis, alpha, X, V); /* * compute approximations of the derivatives (first order in time and * second order in space ) */ derive_approx_fonction(basis, D, alpha,t0,x0); pnl_test_eq_abs (pnl_vect_get(D,0), fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction", "derivative 0"); pnl_test_eq_abs (derive_x_approx_fonction(basis, alpha, t0, x0), derive_x_fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction", "derivative %% x"); pnl_test_eq_abs (pnl_vect_get(D,2), derive_xx_fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction", "derivative %% xx"); pnl_test_eq_abs (pnl_vect_get(D,3), derive_t_fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction", "derivative %% t"); pnl_test_eq_abs (pnl_vect_get(D,4), derive_xt_fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction", "derivative %% tx"); pnl_basis_free (&basis); /* reduced basis */ basis = pnl_basis_create_from_degree (PNL_BASIS_HERMITIAN, deg, 2); lower = pnl_vect_create_from_list (2, 0., -5.); upper = pnl_vect_create_from_list (2, 1., 4.); pnl_basis_set_domain (basis, lower, upper); pnl_basis_fit_ls (basis, alpha, X, V); derive_approx_fonction(basis, D, alpha,t0,x0); pnl_test_eq_abs (pnl_vect_get(D,0), fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction (reduced)", "derivative 0"); pnl_test_eq_abs (derive_x_approx_fonction(basis, alpha, t0, x0), derive_x_fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction (reduced)", "derivative %% x"); pnl_test_eq_abs (pnl_vect_get(D,2), derive_xx_fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction (reduced)", "derivative %% xx"); pnl_test_eq_abs (pnl_vect_get(D,3), derive_t_fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction (reduced)", "derivative %% t"); pnl_test_eq_abs (pnl_vect_get(D,4), derive_xt_fonction_a_retrouver(t0,x0), tol, "deriv_approx_fonction (reduced)", "derivative %% tx"); pnl_basis_free (&basis); pnl_rng_free (&rng); pnl_vect_free(&alpha); pnl_vect_free(&x); pnl_vect_free(&t); pnl_vect_free(&V); pnl_vect_free(&D); pnl_vect_free(&lower); pnl_vect_free(&upper); pnl_mat_free(&X);}
开发者ID:GuillaumeFuchs,项目名称:Ensimag,代码行数:92,
示例18: set_start_bitsstatic BOOLset_start_bits(const uschar *code, uschar *start_bits, BOOL caseless, BOOL utf8, compile_data *cd){register int c;/* This next statement and the later reference to dummy are here in order totrick the optimizer of the IBM C compiler for OS/2 into generating correctcode. Apparently IBM isn't going to fix the problem, and we would rather notdisable optimization (in this module it actually makes a big difference, andthe pcre module can use all the optimization it can get). */volatile int dummy;do { const uschar *tcode = code + 1 + LINK_SIZE; BOOL try_next = TRUE; while (try_next) { /* If a branch starts with a bracket or a positive lookahead assertion, recurse to set bits from within them. That's all for this branch. */ if ((int)*tcode >= OP_BRA || *tcode == OP_ASSERT) { if (!set_start_bits(tcode, start_bits, caseless, utf8, cd)) return FALSE; try_next = FALSE; } else switch(*tcode) { default: return FALSE; /* Skip over callout */ case OP_CALLOUT: tcode += 2; break; /* Skip over extended extraction bracket number */ case OP_BRANUMBER: tcode += 3; break; /* Skip over lookbehind and negative lookahead assertions */ case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: do tcode += GET(tcode, 1); while (*tcode == OP_ALT); tcode += 1+LINK_SIZE; break; /* Skip over an option setting, changing the caseless flag */ case OP_OPT: caseless = (tcode[1] & PCRE_CASELESS) != 0; tcode += 2; break; /* BRAZERO does the bracket, but carries on. */ case OP_BRAZERO: case OP_BRAMINZERO: if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd)) return FALSE; dummy = 1; do tcode += GET(tcode,1); while (*tcode == OP_ALT); tcode += 1+LINK_SIZE; break; /* Single-char * or ? sets the bit and tries the next item */ case OP_STAR: case OP_MINSTAR: case OP_QUERY: case OP_MINQUERY: set_bit(start_bits, tcode[1], caseless, cd); tcode += 2;#ifdef SUPPORT_UTF8 if (utf8) while ((*tcode & 0xc0) == 0x80) tcode++;#endif break; /* Single-char upto sets the bit and tries the next */ case OP_UPTO: case OP_MINUPTO: set_bit(start_bits, tcode[3], caseless, cd); tcode += 4;#ifdef SUPPORT_UTF8 if (utf8) while ((*tcode & 0xc0) == 0x80) tcode++;#endif break; /* At least one single char sets the bit and stops *///.........这里部分代码省略.........
开发者ID:Fighter19,项目名称:PSPMania,代码行数:101,
示例19: find_minlengthstatic intfind_minlength(const uschar *code, const uschar *startcode, int options){int length = -1;BOOL utf8 = (options & PCRE_UTF8) != 0;BOOL had_recurse = FALSE;register int branchlength = 0;register uschar *cc = (uschar *)code + 1 + LINK_SIZE;if (*code == OP_CBRA || *code == OP_SCBRA) cc += 2;/* Scan along the opcodes for this branch. If we get to the end of thebranch, check the length against that of the other branches. */for (;;) { int d, min; uschar *cs, *ce; register int op = *cc; switch (op) { case OP_COND: case OP_SCOND: /* If there is only one branch in a condition, the implied branch has zero length, so we don't add anything. This covers the DEFINE "condition" automatically. */ cs = cc + GET(cc, 1); if (*cs != OP_ALT) { cc = cs + 1 + LINK_SIZE; break; } /* Otherwise we can fall through and treat it the same as any other subpattern. */ case OP_CBRA: case OP_SCBRA: case OP_BRA: case OP_SBRA: case OP_ONCE: d = find_minlength(cc, startcode, options); if (d < 0) return d; branchlength += d; do cc += GET(cc, 1); while (*cc == OP_ALT); cc += 1 + LINK_SIZE; break; /* Reached end of a branch; if it's a ket it is the end of a nested call. If it's ALT it is an alternation in a nested call. If it is END it's the end of the outer call. All can be handled by the same code. */ case OP_ALT: case OP_KET: case OP_KETRMAX: case OP_KETRMIN: case OP_END: if (length < 0 || (!had_recurse && branchlength < length)) length = branchlength; if (*cc != OP_ALT) return length; cc += 1 + LINK_SIZE; branchlength = 0; had_recurse = FALSE; break; /* Skip over assertive subpatterns */ case OP_ASSERT: case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: do cc += GET(cc, 1); while (*cc == OP_ALT); /* Fall through */ /* Skip over things that don't match chars */ case OP_REVERSE: case OP_CREF: case OP_NCREF: case OP_RREF: case OP_NRREF: case OP_DEF: case OP_OPT: case OP_CALLOUT: case OP_SOD: case OP_SOM: case OP_EOD: case OP_EODN: case OP_CIRC: case OP_DOLL: case OP_NOT_WORD_BOUNDARY: case OP_WORD_BOUNDARY: cc += _pcre_OP_lengths[*cc]; break; /* Skip over a subpattern that has a {0} or {0,x} quantifier *///.........这里部分代码省略.........
开发者ID:Kirozen,项目名称:winmerge-v2,代码行数:101,
示例20: memcpyvidTDeint::vidTDeint (AVDMGenericVideoStream * in, CONFcouple * couples){ _in = in; memcpy (&_info, _in->getInfo (), sizeof (_info)); _info.encoding = 1; vidCache = new VideoCache (10, in); _uncompressed=new ADMImage(_info.width,_info.height); scratch=new ADMImage(_info.width,_info.height); scratch2=new ADMImage(_info.width,_info.height); input = cArray = NULL; _param=new TDEINT_PARAM; if(!couples) { _param->mode=0; _param->order=-1; _param->field=-1; _param->mthreshL=6; _param->mthreshC=6; _param->map=0; _param->type=2; _param->debug=0; _param->mtnmode=1; _param->sharp=1; _param->full=1; _param->cthresh=6; _param->blockx=16; _param->blocky=16; _param->chroma=0; _param->MI=64; _param->tryWeave=false; _param->link=2; _param->denoise=true; _param->AP=254; _param->APType=1; } else { GET(mode); GET(order); GET(field); GET(mthreshL); GET(mthreshC); GET(map); GET(type); GET(debug); GET(mtnmode); GET(sharp); GET(full); GET(cthresh); GET(blockx); GET(blocky); GET(chroma); GET(MI); GET(tryWeave); GET(link); GET(denoise); GET(AP); GET(APType); } order=1; orderS=1; mode=0; field=0; fieldS=0; mthreshL=6; mthreshLS=6; mthreshC=6; mthreshCS=6; map=0; ovrDefault=0; type=2; // kernel deint debug=true; mntmode=1; mtnmode=1; sharp=true; hints=false; full=false; cthresh=12; ovr=NULL; input=NULL; blocky=16; blockx=16; chroma=false; MI=64; tryWeave=false; link=2; AP=254; APType=254; reset();}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:99,
示例21: find_minlengthstatic intfind_minlength(const REAL_PCRE *re, const pcre_uchar *code, const pcre_uchar *startcode, int options, int recurse_depth){int length = -1;/* PCRE_UTF16 has the same value as PCRE_UTF8. */BOOL utf = (options & PCRE_UTF8) != 0;BOOL had_recurse = FALSE;register int branchlength = 0;register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE;if (*code == OP_CBRA || *code == OP_SCBRA || *code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += IMM2_SIZE;/* Scan along the opcodes for this branch. If we get to the end of thebranch, check the length against that of the other branches. */for (;;) { int d, min; pcre_uchar *cs, *ce; register pcre_uchar op = *cc; switch (op) { case OP_COND: case OP_SCOND: /* If there is only one branch in a condition, the implied branch has zero length, so we don't add anything. This covers the DEFINE "condition" automatically. */ cs = cc + GET(cc, 1); if (*cs != OP_ALT) { cc = cs + 1 + LINK_SIZE; break; } /* Otherwise we can fall through and treat it the same as any other subpattern. */ case OP_CBRA: case OP_SCBRA: case OP_BRA: case OP_SBRA: case OP_CBRAPOS: case OP_SCBRAPOS: case OP_BRAPOS: case OP_SBRAPOS: case OP_ONCE: case OP_ONCE_NC: d = find_minlength(re, cc, startcode, options, recurse_depth); if (d < 0) return d; branchlength += d; do cc += GET(cc, 1); while (*cc == OP_ALT); cc += 1 + LINK_SIZE; break; /* ACCEPT makes things far too complicated; we have to give up. */ case OP_ACCEPT: case OP_ASSERT_ACCEPT: return -1; /* Reached end of a branch; if it's a ket it is the end of a nested call. If it's ALT it is an alternation in a nested call. If it is END it's the end of the outer call. All can be handled by the same code. If an ACCEPT was previously encountered, use the length that was in force at that time, and pass back the shortest ACCEPT length. */ case OP_ALT: case OP_KET: case OP_KETRMAX: case OP_KETRMIN: case OP_KETRPOS: case OP_END: if (length < 0 || (!had_recurse && branchlength < length)) length = branchlength; if (op != OP_ALT) return length; cc += 1 + LINK_SIZE; branchlength = 0; had_recurse = FALSE; break; /* Skip over assertive subpatterns */ case OP_ASSERT: case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: do cc += GET(cc, 1); while (*cc == OP_ALT); /* Fall through */ /* Skip over things that don't match chars */ case OP_REVERSE: case OP_CREF: case OP_DNCREF: case OP_RREF://.........这里部分代码省略.........
开发者ID:7segments,项目名称:mongo-1,代码行数:101,
示例22: tr_lrs1d_capfloorstatic double tr_lrs1d_capfloor(TreeLRS1D* Meth, ModelLRS1D* ModelParam, ZCMarketData* ZCMarket, int NumberOfTimeStep, NumFunc_1 *p, double s, double r, double periodicity,double first_reset_date,double contract_maturity, double CapFloorFixedRate){ double lambda; double delta_y; // delta_x1 = space step of the process x at time i ; delta_x2 same at time i+1. double delta_t, sqrt_delta_t; // time step double OptionPrice, OptionPrice1, OptionPrice2; int i, i_s, h_r; double theta; double y_r, y_ih, y_00, r_00; double Ti2, Ti1; int i_Ti2, i_Ti1, n; PnlVect* proba_from_ih; PnlVect* OptionPriceVect1; // Matrix of prices of the option at i PnlVect* OptionPriceVect2; // Matrix of prices of the option at i+1 proba_from_ih = pnl_vect_create(3); OptionPriceVect1 = pnl_vect_create(1); OptionPriceVect2 = pnl_vect_create(1); ///********* Model parameters *********/// lambda = (ModelParam->Lambda); ///**************** PAYOFF at the MATURITY of the OPTION : T(n-1)****************/// Ti2 = contract_maturity; Ti1 = Ti2 - periodicity; CapFloor_InitialPayoffLRS1D(Meth, ModelParam, ZCMarket, OptionPriceVect2, p, Ti1, Ti2, CapFloorFixedRate); ///**************** Backward computation of the option price ****************/// n = (int) ((contract_maturity-first_reset_date)/periodicity + 0.1); if(n>1) { for(i = n-2; i>=0; i--) { Ti1 = first_reset_date + i * periodicity; Ti2 = Ti1 + periodicity; i_Ti2 = indiceTimeLRS1D(Meth, Ti2); i_Ti1 = indiceTimeLRS1D(Meth, Ti1); CapFloor_BackwardIterationLRS1D(Meth, ModelParam, ZCMarket, OptionPriceVect1, OptionPriceVect2, i_Ti2, i_Ti1); CapFloor_InitialPayoffLRS1D(Meth, ModelParam, ZCMarket, OptionPriceVect1, p, Ti1, Ti2, CapFloorFixedRate); pnl_vect_plus_vect(OptionPriceVect2, OptionPriceVect1); } } ///****************** Price of the option at initial time s *******************/// i_s = indiceTimeLRS1D(Meth, s); // Localisation of s on the tree delta_t = GET(Meth->t, 1) - GET(Meth->t,0); sqrt_delta_t = sqrt(delta_t); r_00 = -log(BondPrice(GET(Meth->t, 1), ZCMarket))/delta_t; y_00 = r_to_y(ModelParam, r_00); Ti1 = first_reset_date; i_Ti1 = indiceTimeLRS1D(Meth, Ti1); if(i_s==0) // If s=0 { CapFloor_BackwardIterationLRS1D(Meth, ModelParam, ZCMarket, OptionPriceVect1, OptionPriceVect2, i_Ti1, 1); probabilities(GET(Meth->t,0), y_00, 0, lambda, sqrt_delta_t, ModelParam, ZCMarket, proba_from_ih); OptionPrice = exp(-r_00*delta_t) * ( GET(proba_from_ih,0) * GET(OptionPriceVect1, 0) + GET(proba_from_ih,1) * GET(OptionPriceVect1,1) + GET(proba_from_ih,2) * GET(OptionPriceVect1, 2)); } else { // We compute the price of the option as a linear interpolation of the prices at the nodes r(i_s,j_r) and r(i_s,j_r+1) delta_t = GET(Meth->t, i_s+1) - GET(Meth->t,i_s); sqrt_delta_t = sqrt(delta_t); delta_y = lambda * sqrt_delta_t; y_r = r_to_y(ModelParam, r); h_r = (int) floor(i_s - (y_r-y_00)/delta_y); // y_r between y(h_r) et y(h_r+1) : y(h_r+1) < y_r <= y(h_r) y_ih = y_00 + (i_s-h_r) * delta_y; if(h_r < 0 || h_r > 2*i_s) { printf("WARNING : Instantaneous futur spot rate is out of tree/n"); exit(EXIT_FAILURE); } CapFloor_BackwardIterationLRS1D(Meth, ModelParam, ZCMarket, OptionPriceVect1, OptionPriceVect2, i_Ti1, i_s); theta = (y_ih - y_r)/delta_y; OptionPrice1 = MeanPrice(Meth, i_s, h_r, OptionPriceVect2); //Interpolation(Meth, i_s, h_r , OptionPriceVect2, phi0); OptionPrice2 = MeanPrice(Meth, i_s, h_r+1, OptionPriceVect2); // Interpolation(Meth, i_s, h_r+1 , OptionPriceVect2, phi0);//.........这里部分代码省略.........
开发者ID:jayhsieh,项目名称:premia-13,代码行数:101,
示例23: memcpyDecimate::Decimate(AVDMGenericVideoStream *in,CONFcouple *couples) {{ int count = 0; char buf[80]; unsigned int *p; _in=in; memcpy(&_info,_in->getInfo(),sizeof(_info)); _info.encoding=1; _uncompressed=NULL; _info.encoding=1; // // Init here debug=0; show=0; #ifdef USE_SSE if(CpuCaps::hasSSE()) { printf("Decimate:SSE enabled/n"); }#endif // _param=new DECIMATE_PARAM; if(couples) { GET(cycle); GET(mode); GET(quality); GET(threshold); GET(threshold2); } else // Default { _param->cycle=5; _param->mode=0; _param->quality=2; _param->threshold=0; _param->threshold2=3.0; } ADM_assert(_param->cycle); vidCache=new VideoCache(_param->cycle*2+1,in); if (_param->mode == 0 || _param->mode == 2 || _param->mode == 3) { num_frames_hi = _info.nb_frames; _info.nb_frames = _info.nb_frames * (_param->cycle - 1) / _param->cycle; _info.fps1000=_info.fps1000*(_param->cycle-1); _info.fps1000=(uint32_t)(_info.fps1000/_param->cycle); } last_request = -1; firsttime = true; sum = (unsigned int *) ADM_alloc(MAX_BLOCKS * MAX_BLOCKS * sizeof(unsigned int)); ADM_assert(sum); all_video_cycle = true; if (debug) { char b[80]; sprintf(b, "Decimate %s by Donald Graft, Copyright 2003/n", VERSION); OutputDebugString(b); } }}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:69,
示例24: CapFloor_BackwardIterationLRS1D/// Backward computation of the price of a Zero Coupon Bondstatic void CapFloor_BackwardIterationLRS1D(TreeLRS1D* Meth, ModelLRS1D* ModelParam, ZCMarketData* ZCMarket, PnlVect* OptionPriceVect1, PnlVect* OptionPriceVect2, int index_last, int index_first){ double sigma, rho, kappa, lambda; int i, j, h; double delta_y, delta_t, sqrt_delta_t; double price_up, price_middle, price_down; double y_00, y_ih, r_ih, phi_ihj, phi_next; PnlVect* proba_from_ij; proba_from_ij = pnl_vect_create(3); ///********* Model parameters *********/// kappa = (ModelParam->Kappa); sigma = (ModelParam->Sigma); rho = (ModelParam->Rho); lambda = (ModelParam->Lambda); delta_t = GET(Meth->t, 1) - GET(Meth->t,0); y_00 = r_to_y(ModelParam, -log(BondPrice(GET(Meth->t, 1), ZCMarket))/delta_t); for(i = index_last-1; i>=index_first; i--) { pnl_vect_resize(OptionPriceVect1, 6*i-3); // OptionPriceVect1 := Price of the bond in the tree at time t(i) delta_t = GET(Meth->t, i+1) - GET(Meth->t,i); sqrt_delta_t = sqrt(delta_t); delta_y = lambda * sqrt_delta_t; for( h=0; h<=2*i; h++) /// h : numero de la box { y_ih = y_00 + (i-h) * delta_y; r_ih = y_to_r(ModelParam, y_ih); for(j=0;j<number_phi_in_box(i, h);j++) /// Boucle sur les valeurs de phi à (i,h) { phi_ihj = phi_value(Meth, i, h, j); phi_next = phi_ihj * (1-2*kappa*delta_t) + SQR(sigma) * pow(y_to_r(ModelParam, y_ih), (2*rho)) * delta_t; price_up = Interpolation(Meth, i+1, h , OptionPriceVect2, phi_next); price_middle = Interpolation(Meth, i+1, h+1, OptionPriceVect2, phi_next); price_down = Interpolation(Meth, i+1, h+2, OptionPriceVect2, phi_next); probabilities(GET(Meth->t,i), y_ih, phi_ihj, lambda, sqrt_delta_t, ModelParam, ZCMarket, proba_from_ij); LET(OptionPriceVect1, index_tree(i,h,j)) = exp(-r_ih*delta_t) * (GET(proba_from_ij,0) * price_up + GET(proba_from_ij,1) * price_middle + GET(proba_from_ij,2) * price_down ); } } pnl_vect_clone(OptionPriceVect2, OptionPriceVect1); // Copy OptionPriceVect1 in OptionPriceVect2 } // END of the loop on i (time) pnl_vect_free(&proba_from_ij);}
开发者ID:jayhsieh,项目名称:premia-13,代码行数:62,
示例25: poll_losstatic void poll_los(struct atm_dev *dev){ dev->signal = GET(RSOP_SIS) & SUNI_RSOP_SIS_LOSV ? ATM_PHY_SIG_LOST : ATM_PHY_SIG_FOUND;}
开发者ID:PennPanda,项目名称:linux-repo,代码行数:5,
示例26: fill_tracks_from_mediumstatic voidfill_tracks_from_medium (Mb4Medium medium, AlbumDetails *album){ Mb4TrackList track_list; GList *tracks; unsigned int i; char buffer[512]; /* for the GET() macro */ track_list = mb4_medium_get_tracklist (medium); if (!track_list) return; album->number = mb4_track_list_size (track_list); tracks = NULL; for (i = 0; i < mb4_track_list_size (track_list); i++) { Mb4Track mbt; Mb4ArtistCredit credit; Mb4Recording recording; TrackDetails *track; mbt = mb4_track_list_item (track_list, i); if (!mbt) continue; track = g_new0 (TrackDetails, 1); track->album = album; track->number = mb4_track_get_position (mbt); recording = mb4_track_get_recording (mbt); if (recording != NULL) { GET (track->title, mb4_recording_get_title, recording); GET (track->track_id, mb4_recording_get_id, recording); track->duration = mb4_recording_get_length (recording) / 1000; credit = mb4_recording_get_artistcredit (recording); } else { GET (track->title, mb4_track_get_title, mbt); track->duration = mb4_track_get_length (mbt) / 1000; credit = mb4_track_get_artistcredit (mbt); } if (credit) { GList *artists; artists = get_artist_list (credit); if (artists) { get_artist_info (artists, &track->artist, &track->artist_sortname, &track->artist_id); } track->artists = artists; } if (track->artist == NULL) track->artist = g_strdup (album->artist); if (track->artist_sortname == NULL) track->artist_sortname = g_strdup (album->artist_sortname); if (track->artist_id == NULL) track->artist_id = g_strdup (album->artist_id); tracks = g_list_prepend (tracks, track); } album->tracks = g_list_reverse (tracks);}
开发者ID:Sprezzatech,项目名称:gtkpod,代码行数:64,
示例27: do_frdint do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]){ unsigned int fslnum; unsigned int num; unsigned int blocking; if (argc < 2) { cmd_usage(cmdtp); return 1; } fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16); blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16); if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) { puts ("Bad number of FSL/n"); cmd_usage(cmdtp); return 1; } switch (fslnum) {#if (XILINX_FSL_NUMBER > 0) case 0: switch (blocking) { case 0: NGET (num, 0); break; case 1: NCGET (num, 0); break; case 2: GET (num, 0); break; case 3: CGET (num, 0); break; default: return 2; } break;#endif#if (XILINX_FSL_NUMBER > 1) case 1: switch (blocking) { case 0: NGET (num, 1); break; case 1: NCGET (num, 1); break; case 2: GET (num, 1); break; case 3: CGET (num, 1); break; default: return 2; } break;#endif#if (XILINX_FSL_NUMBER > 2) case 2: switch (blocking) { case 0: NGET (num, 2); break; case 1: NCGET (num, 2); break; case 2: GET (num, 2); break; case 3: CGET (num, 2); break; default: return 2; } break;#endif#if (XILINX_FSL_NUMBER > 3) case 3: switch (blocking) { case 0: NGET (num, 3); break; case 1: NCGET (num, 3); break; case 2: GET (num, 3); break; case 3: CGET (num, 3); break; default: return 2; } break;#endif#if (XILINX_FSL_NUMBER > 4) case 4: switch (blocking) { case 0: NGET (num, 4); break; case 1: NCGET (num, 4); break; case 2: GET (num, 4); break; case 3: CGET (num, 4); break; default: return 2; } break;#endif//.........这里部分代码省略.........
开发者ID:OpenInkpot-archive,项目名称:uboot-n516,代码行数:101,
示例28: mb4_list_albums/* * Virtual methods */static GList *mb4_list_albums (SjMetadata *metadata, char **url, GError **error){ SjMetadataMusicbrainz4Private *priv; GList *albums = NULL; Mb4ReleaseList releases; Mb4Release release; const char *discid = NULL; char buffer[1024]; int i; g_return_val_if_fail (SJ_IS_METADATA_MUSICBRAINZ4 (metadata), NULL); priv = GET_PRIVATE (metadata); if (sj_metadata_helper_check_media (priv->cdrom, error) == FALSE) { return NULL; } priv->disc = discid_new (); if (priv->disc == NULL) return NULL; if (discid_read (priv->disc, priv->cdrom) == 0) return NULL; if (url != NULL) *url = g_strdup (discid_get_submission_url (priv->disc)); if (g_getenv("MUSICBRAINZ_FORCE_DISC_ID")) { discid = g_getenv("MUSICBRAINZ_FORCE_DISC_ID"); } else { discid = discid_get_id (priv->disc); } releases = mb4_query_lookup_discid(priv->mb, discid); if (releases == NULL) { return NULL; } if (mb4_release_list_size (releases) == 0) { return NULL; } for (i = 0; i < mb4_release_list_size (releases); i++) { AlbumDetails *album; release = mb4_release_list_item (releases, i); if (release) { char *releaseid = NULL; Mb4Release full_release; releaseid = NULL; GET(releaseid, mb4_release_get_id, release); full_release = mb4_query_lookup_release (priv->mb, releaseid); g_free (releaseid); if (full_release) { Mb4MediumList media; Mb4Metadata metadata = NULL; Mb4ReleaseGroup group; unsigned int j; group = mb4_release_get_releasegroup (full_release); if (group) { /* The release-group information we can extract from the * lookup_release query doesn't have the url relations for the * release-group, so run a separate query to get these urls */ char *releasegroupid = NULL; char *params_names[] = { "inc" }; char *params_values[] = { "artists url-rels" }; GET (releasegroupid, mb4_releasegroup_get_id, group); metadata = mb4_query_query (priv->mb, "release-group", releasegroupid, "", 1, params_names, params_values); g_free (releasegroupid); } if (metadata && mb4_metadata_get_releasegroup (metadata)) group = mb4_metadata_get_releasegroup (metadata); media = mb4_release_media_matching_discid (full_release, discid); for (j = 0; j < mb4_medium_list_size (media); j++) { Mb4Medium medium; medium = mb4_medium_list_item (media, j); if (medium) { album = make_album_from_release (group, full_release, medium); album->metadata_source = SOURCE_MUSICBRAINZ; albums = g_list_append (albums, album); } } mb4_metadata_delete (metadata); mb4_medium_list_delete (media); mb4_release_delete (full_release); } } }//.........这里部分代码省略.........
开发者ID:Sprezzatech,项目名称:gtkpod,代码行数:101,
示例29: is_epiloguestatic int is_epilogue(void *bp){ /* return GET_SIZE(HDRP(bp)) == 0 && GET_ALLOC(HDRP(bp)); */ return 1 == GET(HDRP(bp));}
开发者ID:Jarvishappy,项目名称:malloc_lab,代码行数:5,
示例30: handle_motorsvoid handle_motors() { if (step_state == 1) return; last_active = seconds(); cli(); uint8_t state = step_state; uint8_t cf = current_fragment; uint8_t cs = current_sample; sei(); // Check probe. bool probed; if (settings[cf].flags & Settings::PROBING && probe_pin < NUM_DIGITAL_PINS) { if (state == 0) { if (GET(probe_pin) ^ bool(pin_flags & 2)) stopping = active_motors; probed = true; } else probed = false; } else probed = true; // If we didn't need to probe; don't block later on. if (stopping < 0) { // Check sensors. for (uint8_t m = 0; m < active_motors; ++m) { if (!(motor[m].intflags & Motor::ACTIVE)) continue; //debug("check %d", m); // Check sense pins. if (motor[m].sense_pin < NUM_DIGITAL_PINS) { if (GET(motor[m].sense_pin) ^ bool(motor[m].flags & Motor::SENSE_STATE)) { //debug("sense %d %x", m, motor[m].flags); motor[m].flags ^= Motor::SENSE_STATE; motor[m].flags |= (motor[m].flags & Motor::SENSE_STATE ? Motor::SENSE1 : Motor::SENSE0); uint8_t sense_state = motor[m].flags & Motor::SENSE_STATE ? 1 : 0; cli(); for (int mi = 0; mi < active_motors; ++mi) motor[mi].sense_pos[sense_state] = motor[mi].current_pos; sei(); } } // Check limit switches. if (stopping < 0) { int8_t value = buffer[cf][m][cs]; if (value == 0) continue; uint8_t limit_pin = value < 0 ? motor[m].limit_min_pin : motor[m].limit_max_pin; if (limit_pin < NUM_DIGITAL_PINS) { bool inverted = motor[m].flags & (value < 0 ? Motor::INVERT_LIMIT_MIN : Motor::INVERT_LIMIT_MAX); if (GET(limit_pin) ^ inverted) { debug("hit %d pos %d state %d sample %d", m, motor[m].current_pos, state, buffer[cf][m][cs]); stopping = m; motor[m].flags |= Motor::LIMIT; break; } } } } } if (stopping >= 0) { // Hit endstop or probe; disable timer interrupt. step_state = 1; //debug("hit limit %d curpos %ld cf %d ncf %d lf %d cfp %d", m, F(motor[m].current_pos), cf, notified_current_fragment, last_fragment, cs); // Notify host. limit_fragment_pos = cs; arch_set_speed(0); return; } if (homers > 0) { // Homing. if (state == 0) { probed = true; for (uint8_t m = 0; m < active_motors; ++m) { if (!(motor[m].intflags & Motor::ACTIVE)) continue; // Get twe "wrong" limit pin for the given direction. uint8_t limit_pin = (buffer[cf][m][cs] < 0 ? motor[m].limit_max_pin : motor[m].limit_min_pin); bool inverted = motor[m].flags & (buffer[cf][m][cs] < 0 ? Motor::INVERT_LIMIT_MAX : Motor::INVERT_LIMIT_MIN); if (limit_pin >= NUM_DIGITAL_PINS || GET(limit_pin) ^ inverted) { // Limit pin still triggered; continue moving. continue; } // Limit pin no longer triggered. Stop moving and possibly notify host. motor[m].intflags &= ~Motor::ACTIVE; if (!--homers) { arch_set_speed(0); return; } } } else probed = false; } if (state == 0 && probed) { if (homers > 0) current_sample = 0; // Use only the first sample for homing. step_state = homers > 0 || (settings[cf].flags & Settings::PROBING) ? 2 : 3; }}
开发者ID:plastbotindustries,项目名称:franklin,代码行数:99,
注:本文中的GET函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GET2函数代码示例 C++ GEOSGeom_destroy_r函数代码示例 |