static tree chrec_evaluate (unsigned var, tree chrec, tree n, unsigned int k) { tree arg0, arg1, binomial_n_k; tree type = TREE_TYPE (chrec); while (TREE_CODE (chrec) == POLYNOMIAL_CHREC && CHREC_VARIABLE (chrec) > var) chrec = CHREC_LEFT (chrec); if (TREE_CODE (chrec) == POLYNOMIAL_CHREC && CHREC_VARIABLE (chrec) == var) { arg0 = chrec_evaluate (var, CHREC_RIGHT (chrec), n, k + 1); if (arg0 == chrec_dont_know) return chrec_dont_know; binomial_n_k = tree_fold_binomial (type, n, k); if (!binomial_n_k) return chrec_dont_know; arg1 = fold (build2 (MULT_EXPR, type, CHREC_LEFT (chrec), binomial_n_k)); return chrec_fold_plus (type, arg0, arg1); } binomial_n_k = tree_fold_binomial (type, n, k); if (!binomial_n_k) return chrec_dont_know; return fold (build2 (MULT_EXPR, type, chrec, binomial_n_k)); }
int main(int argc, char *argv[]) { char c; long width = 80; FILE *fp; while((c = getopt(argc, argv, "bsw:")) != -1) switch(c) { case 'b': bflag = true; break; case 's': sflag = true; break; case 'w': width = estrtol(optarg, 0); break; default: exit(EXIT_FAILURE); } if(optind == argc) fold(stdin, width); else for(; optind < argc; optind++) { if(strcmp(argv[optind], "-") == 0) argv[optind] = "/dev/stdin"; if(!(fp = fopen(argv[optind], "r"))) eprintf("fopen %s:", argv[optind]); fold(fp, width); fclose(fp); } return EXIT_SUCCESS; }
static inline const typename Tensor::elt_t do_expected12(const iTEBD<Tensor> &psi, const Tensor &Op12, int site) { if (!psi.is_canonical()) { return do_expected12(psi.canonical_form(), Op12, site); } else { tensor::index a, i, b, j; const Tensor &AlA = psi.combined_matrix(0); const Tensor &BlB = psi.combined_matrix(1); AlA.get_dimensions(&a, &i, &b); BlB.get_dimensions(&b, &j, &a); Tensor v1 = psi.left_boundary(0); Tensor v2 = v1; if (site & 1) { v1 = propagate_right(v1, AlA); v2 = v1; const Tensor BlBAlA = reshape(fold(BlB, -1, AlA, 0), b, j*i, b); v1 = propagate_right(v1, BlBAlA, Op12); v2 = propagate_right(v2, BlBAlA); v1 = propagate_right(v1, BlB); v2 = propagate_right(v2, BlB); } else { const Tensor AlABlB = reshape(fold(AlA, -1, BlB, 0), a, i*j, a); v1 = propagate_right(v1, AlABlB, Op12); v2 = propagate_right(v2, AlABlB); } return trace(v1) / trace(v2); } }
tree convert_force (tree type, tree expr, int convtype) { tree e = expr; enum tree_code code = TREE_CODE (type); if (code == REFERENCE_TYPE) return fold (convert_to_reference (type, e, CONV_C_CAST, LOOKUP_COMPLAIN, NULL_TREE)); else if (TREE_CODE (TREE_TYPE (e)) == REFERENCE_TYPE) e = convert_from_reference (e); if (code == POINTER_TYPE) return fold (convert_to_pointer_force (type, e)); /* From typeck.c convert_for_assignment */ if (((TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE && TREE_CODE (e) == ADDR_EXPR && TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE && TREE_CODE (TREE_TYPE (TREE_TYPE (e))) == METHOD_TYPE) || integer_zerop (e) || TYPE_PTRMEMFUNC_P (TREE_TYPE (e))) && TYPE_PTRMEMFUNC_P (type)) { /* compatible pointer to member functions. */ return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), e, 1); } return ocp_convert (type, e, CONV_C_CAST|convtype, LOOKUP_NORMAL); }
int run(int W, int H, int A) { vector<int> P; // 素因数を求める // たかだか100K回 for(int i = 1; i <= A; i++) if(A % i == 0){ P.push_back(i); } int mi = min(W, H); int ma = max(W, H); int ans = INF; // Pは素因数の結果なので要素数は少ない for(int i = 0; i < P.size(); i++){ // x <= yが成立 int x = P[i]; int y = A / x; // 折り畳めることが可能な条件 if (x <= mi && y <= ma){ int times = fold(x, mi) + fold(y, ma); // P(times)P(x)P(y) ans = min(ans, times); } } return ans == INF ? -1 : ans; }
int main () { bool (*pointerToComparator) (int,int); //pointerToComparator std::cout << compareGt (1,2); //std::cout << (long*)compareGt << std::endl; //std::cout << (long*)compareLt << std::endl; pointerToComparator = compareLt; std::cout << pointerToComparator (2,1) << std::endl; int arr [] = {25,3563,473845,733,7,457,567,63,5}; std::cout << arr[findExtremum (arr,9,compareGt)] << std::endl << arr[findExtremum (arr,9,compareLt)] << std::endl; double darr [] = {42342.4,234234.5757,535.2423,545.435,346.34}; std::cout << darr[findExtremum (darr,5,compareGt)] << std::endl << std::setprecision (3) << darr[findExtremum (darr,5,compareLt)] << std::endl; std::cout << "Sum of all ints = " << fold (arr,9,0,plus) << std::endl << "Product of all ints = " << fold (arr,9,1,mult) << std::endl << "Count ints = " << fold (arr,9,0,sumones) << std::endl << "Find even = " << fold (arr,9,false,checkAtLeastOneEven<int>) << std::endl; printArray(arr,9); std::cout << std::endl; map (arr,9,inc); printArray(arr,9); map (arr,9,mult2); std::cout << std::endl; printArray(arr,9); std::cout << std::endl; size_t newSize = 0; int *newarr = filter (arr,9,check500,newSize); printArray (newarr,newSize); delete newarr; return 0; }
static u16 bracket_handler(u8 *c,u8 **pc,u8 **sc,void *str_end,u8 flgs) { u8 *pc_init=*pc; if(*sc==str_end) return RETURN_R|R_SET(NOMATCH); u8 not=(**pc=='!'||**pc=='^'); if(not) ++(*pc); u8 sc_folded=fold(**sc,flgs); *c=*(*pc)++; while(1){ if(*c=='\\'){ u16 r=bracket_escape(c,pc,flgs,not,sc_folded); if(r!=OK) return r; }else if(*c=='['&&**pc==':'){ u16 r=bracket_class(c,pc,sc,not,sc_folded); if(r!=OK) return r; }else if(c=='\0'){//[ unterminated, rewind and tell above to match normal *pc=pc_init; *c='['; return MATCH_NORMAL; }else{ *c=fold(*c,flgs); u16 r=bracket_normal(c,pc,not,sc_folded); if(r!=0) return r; } if(*c==']') break; } if(!not) return RETURN_R|R_SET(NOMATCH); return NEXT_STR_CHAR; }
int main(int argc, char *argv[]) { int ch, lastch, newarg, prevoptind, width; const char *errstr; width = 0; lastch = '\0'; prevoptind = 1; newarg = 1; while ((ch = getopt(argc, argv, "0123456789bsw:")) != -1) { switch (ch) { case 'b': count_bytes = 1; break; case 's': split_words = 1; break; case 'w': width = strtonum(optarg, 1, INT_MAX, &errstr); if (errstr != NULL) errx(1, "illegal width value, %s: %s", errstr, optarg); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (newarg) width = 0; else if (!isdigit(lastch)) usage(); if (width > INT_MAX / 10) errx(1, "illegal width value, too large"); width = (width * 10) + (ch - '0'); if (width < 1) errx(1, "illegal width value, too small"); break; default: usage(); } lastch = ch; newarg = optind != prevoptind; prevoptind = optind; } argv += optind; argc -= optind; if (width == 0) width = DEFLINEWIDTH; if (!*argv) fold(width); else for (; *argv; ++argv) if (!freopen(*argv, "r", stdin)) { err(1, "%s", *argv); /* NOTREACHED */ } else fold(width); exit(0); }
static TDHS_INLINE uint64_t calc_hash_get(const tdhs_request_t &req) { uint64_t hash = fold(calc_hash_table(req.table_info), calc_hash_keys(req.get.key_num, req.get.keys)); hash = fold(hash, easy_hash_key((uint64_t) req.get.find_flag)); hash = fold(hash, easy_hash_key((uint64_t) req.get.start)); hash = fold(hash, easy_hash_key((uint64_t) req.get.limit)); return hash; }
tree convert (tree type, tree expr) { tree e = expr; enum tree_code code = TREE_CODE (type); const char *invalid_conv_diag; if (type == error_mark_node || expr == error_mark_node || TREE_TYPE (expr) == error_mark_node) return error_mark_node; if ((invalid_conv_diag = targetm.invalid_conversion (TREE_TYPE (expr), type))) { error (invalid_conv_diag); return error_mark_node; } if (type == TREE_TYPE (expr)) return expr; if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr))) return fold_convert (type, expr); if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) return error_mark_node; if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE) { error ("void value not ignored as it ought to be"); return error_mark_node; } if (code == VOID_TYPE) return fold_convert (type, e); // check if (code == INTEGER_TYPE && TREE_CODE(expr) == STRING_CST) { char *c = TREE_STRING_POINTER(expr)+1; return build_int_cst(type, *c); } if (code == INTEGER_TYPE || code == ENUMERAL_TYPE) return fold (convert_to_integer (type, e)); if (code == BOOLEAN_TYPE) return fold_convert (type, c_objc_common_truthvalue_conversion (expr)); if (code == POINTER_TYPE || code == REFERENCE_TYPE) return fold (convert_to_pointer (type, e)); if (code == REAL_TYPE) return fold (convert_to_real (type, e)); if (code == COMPLEX_TYPE) return fold (convert_to_complex (type, e)); if (code == VECTOR_TYPE) return fold (convert_to_vector (type, e)); if ((code == RECORD_TYPE || code == UNION_TYPE) && lang_hooks.types_compatible_p (type, TREE_TYPE (expr))) return e; error ("conversion to non-scalar type requested"); return error_mark_node; }
void World::init (int sizeX, int sizeY, int sizeV, int tDur, double lRate) { int x, y, i, j, nCount = 0; double state; this->clear(); _sizeX = sizeX; _sizeY = sizeY; _vectorSize = sizeV; _trainDur = tDur; _learningRate = lRate; _initLearningRate = lRate; _mapRadius = (double)max(_sizeX, _sizeY) / 2.0f; _timeConst = (double)(_trainDur / logf(_mapRadius)); for (int i = 0; i < 8; i++) neighborWeights.push_back(1.0); nodes = new Node*[_sizeX]; assert(nodes); for (x = 0; x < _sizeX; x++) { nodes[x] = new Node[_sizeY]; assert(nodes[x]); for (y = 0; y < _sizeY; y++) { nodes[x][y].x = x; nodes[x][y].y = y; for (i = 0; i < _vectorSize; i++) { state = randd(); nodes[x][y].weights.push_back(state); } state = randd(); for (i = 0; i < 3; i++) { nodes[x][y].states[i] = 0; } } } for (x = 0; x < _sizeX; x++) { for (y = 0; y < _sizeY; y++) { nCount = 0; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { if (!(i == 1 && j == 1)) { // nodes[x][y].neighbors[nCount] = &(nodes[wrapi(x+(i-1), 0, _sizeX-1)][wrapi(y+(j-1), 0, _sizeY-1)]); nodes[x][y].neighbors[nCount] = &(nodes[fold(x+(i-1), 0, _sizeX-1)][fold(y+(j-1), 0, _sizeY-1)]); nCount++; } } } } } }
/* We are assuming that given a SIMPLE val, the result will be a SIMPLE rhs. If this is not the case, we will abort with an internal error. */ tree convert (tree type, tree expr) { tree e = expr; enum tree_code code = TREE_CODE (type); if (type == TREE_TYPE (expr) || TREE_CODE (expr) == ERROR_MARK || code == ERROR_MARK || TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) return expr; if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr))) return fold_build1 (NOP_EXPR, type, expr); if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) return error_mark_node; if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE) { error ("void value not ignored as it ought to be"); return error_mark_node; } if (code == VOID_TYPE) return fold_build1 (CONVERT_EXPR, type, e); #if 0 /* This is incorrect. A truncation can't be stripped this way. Extensions will be stripped by the use of get_unwidened. */ if (TREE_CODE (expr) == NOP_EXPR) return convert (type, TREE_OPERAND (expr, 0)); #endif if (code == INTEGER_TYPE || code == ENUMERAL_TYPE) return fold (convert_to_integer (type, e)); if (code == BOOLEAN_TYPE) { e = gfc_truthvalue_conversion (e); /* If we have a NOP_EXPR, we must fold it here to avoid infinite recursion between fold () and convert (). */ if (TREE_CODE (e) == NOP_EXPR) return fold_build1 (NOP_EXPR, type, TREE_OPERAND (e, 0)); else return fold_build1 (NOP_EXPR, type, e); } if (code == POINTER_TYPE || code == REFERENCE_TYPE) return fold (convert_to_pointer (type, e)); if (code == REAL_TYPE) return fold (convert_to_real (type, e)); if (code == COMPLEX_TYPE) return fold (convert_to_complex (type, e)); if (code == VECTOR_TYPE) return fold (convert_to_vector (type, e)); error ("conversion to non-scalar type requested"); return error_mark_node; }
tree UI_To_gnu (Uint Input, tree type) { tree gnu_ret; if (Input <= Uint_Direct_Last) gnu_ret = build_cst_from_int (type, Input - Uint_Direct_Bias); else { Int Idx = Uints_Ptr[Input].Loc; Pos Length = Uints_Ptr[Input].Length; Int First = Udigits_Ptr[Idx]; /* Do computations in integer type or TYPE whichever is wider, then convert later. This avoid overflow if type is short integer. */ tree comp_type = ((TREE_CODE (type) == REAL_TYPE || TYPE_PRECISION (type) >= TYPE_PRECISION (integer_type_node)) ? type : integer_type_node); tree gnu_base = build_cst_from_int (comp_type, Base); gcc_assert (Length > 0); gnu_ret = build_cst_from_int (comp_type, First); if (First < 0) for (Idx++, Length--; Length; Idx++, Length--) gnu_ret = fold (build2 (MINUS_EXPR, comp_type, fold (build2 (MULT_EXPR, comp_type, gnu_ret, gnu_base)), build_cst_from_int (comp_type, Udigits_Ptr[Idx]))); else for (Idx++, Length--; Length; Idx++, Length--) gnu_ret = fold (build2 (PLUS_EXPR, comp_type, fold (build2 (MULT_EXPR, comp_type, gnu_ret, gnu_base)), build_cst_from_int (comp_type, Udigits_Ptr[Idx]))); } gnu_ret = convert (type, gnu_ret); /* We don't need any NOP_EXPR or NON_LVALUE_EXPR on GNU_RET. */ while ((TREE_CODE (gnu_ret) == NOP_EXPR || TREE_CODE (gnu_ret) == NON_LVALUE_EXPR) && TREE_TYPE (TREE_OPERAND (gnu_ret, 0)) == TREE_TYPE (gnu_ret)) gnu_ret = TREE_OPERAND (gnu_ret, 0); return gnu_ret; }
int main(int argc, char **argv) { long long offset = 0; int nbin, nint; double freq; int retval; if(argc < 6) { usage(argv[0]); return EXIT_FAILURE; } oldsiginthand = signal(SIGINT, siginthand); nbin = atol(argv[3]); nint = atol(argv[4]); freq = atof(argv[5]); /* if supplied nint is non-sensical, assume whole file */ if(nint <= 0) { nint = 2000000000L; } if(argc > 7) { offset = atoll(argv[7]); } retval = fold(argv[1], argv[2], nbin, nint, freq, argv[6], offset); return retval; }
static void function (char const * colors [], unsigned count, flag_t flags) { if (_anyset (flags, (OFFSET_HTML | OFFSET_PAGE))) { html (colors, count, flags); } else if (_anyset (flags, (OFFSET_TEXT))) { tabs (flags); } else if (_anyset (flags, (OFFSET_EFSU))) { efsu (flags); } else if (_anyset (flags, (OFFSET_FOLD))) { fold (flags); } else if (_anyset (flags, (OFFSET_ZERO))) { zero (flags); } else { text (flags); } return; }
TaskHeader::TaskHeader(const QIcon &icon, const QString &title, bool expandable, QWidget *parent) : BaseClass(parent), myExpandable(expandable), m_over(false), m_buttonOver(false), m_fold(true), m_opacity(0.1), myButton(0) { setProperty("class", "header"); myTitle = new ActionLabel(this); myTitle->setProperty("class", "header"); myTitle->setText(title); myTitle->setIcon(icon); myTitle->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); connect(myTitle, SIGNAL(clicked()), this, SLOT(fold())); QHBoxLayout *hbl = new QHBoxLayout(); hbl->setMargin(2); setLayout(hbl); hbl->addWidget(myTitle); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); setScheme(ActionPanelScheme::defaultScheme()); //myTitle->setSchemePointer(&myLabelScheme); setExpandable(myExpandable); }
void JSEdit::toggleFold(int line) { if (isFolded(line)) unfold(line); else fold(line); }
iisTaskHeader::iisTaskHeader(const QIcon &icon, const QString &title, bool expandable, QWidget *parent) : QFrame(parent), myExpandable(expandable), m_over(false), m_buttonOver(false), m_fold(true), m_opacity(0.1), myButton(0) { myTitle = new iisIconLabel(icon, title, this); myTitle->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); connect(myTitle, SIGNAL(activated()), this, SLOT(fold())); QHBoxLayout *hbl = new QHBoxLayout(); hbl->setMargin(2); setLayout(hbl); hbl->addWidget(myTitle); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); setScheme(iisTaskPanelScheme::defaultScheme()); myTitle->setSchemePointer(&myLabelScheme); if (myExpandable) { myButton = new QLabel(this); hbl->addWidget(myButton); myButton->installEventFilter(this); myButton->setFixedWidth(myScheme->headerButtonSize.width()); changeIcons(); } }
RNAProfileAlignment::RNAProfileAlignment(const string &baseStr, const string &name, const string &constraint, double t) : PPForestAli<RNA_Alphabet_Profile,RNA_Alphabet_Profile>(2*baseStr.length()), m_name(name), m_numStructures(1) { char *viennaStr=NULL; // calculate partition function for the sequence do_backtrack=1; init_pf_fold(baseStr.length()); //if(constraint.length()>0) //pf_fold((char*)baseStr.c_str(),(char*)constraint.c_str()); // expicit conversion to non-const value, but pf_fold does not alter baseStr //else pf_fold((char*)baseStr.c_str(),NULL); // expicit conversion to non-const value, but pf_fold does not alter baseStr viennaStr=new char[baseStr.length()+1]; dangles=2; fold((char*)baseStr.c_str(),viennaStr); setSize(RNAFuncs::treeSize(viennaStr)); buildForest(baseStr,viennaStr,true); free_pf_arrays(); delete[] viennaStr; // hasSequence=true; addStrName(name); }
int testOverLongWord(void) { char *input = "abcde"; char *expected = "abcd.e"; char output[MAXLINE] = ""; tf_assert(strcmp(fold(input, output, FOLDPOINT), expected) == 0, "Expected '%s' was '%s'", expected, output); tf_passed(); }
int testBasicFolding(void) { char *input = "abc def"; char *expected = "abc.def"; char output[MAXLINE] = ""; tf_assert(strcmp(fold(input, output, FOLDPOINT), expected) == 0, "Expected '%s' was '%s'", expected, output); tf_passed(); }
ui ComputerPlayer::call(ui previous) { if (money < previous) return fold(); money -= previous; std::cout << getName() << " is calling\n"; return previous; }
static tree java_build_function_call_expr (tree fn, tree orig_call) { int nargs = call_expr_nargs (orig_call); switch (nargs) { /* Although we could handle the 0-3 argument cases using the general logic in the default case, splitting them out permits folding to be performed without constructing a temporary CALL_EXPR. */ case 0: return build_call_expr (fn, 0); case 1: return build_call_expr (fn, 1, CALL_EXPR_ARG (orig_call, 0)); case 2: return build_call_expr (fn, 2, CALL_EXPR_ARG (orig_call, 0), CALL_EXPR_ARG (orig_call, 1)); case 3: return build_call_expr (fn, 3, CALL_EXPR_ARG (orig_call, 0), CALL_EXPR_ARG (orig_call, 1), CALL_EXPR_ARG (orig_call, 2)); default: { tree fntype = TREE_TYPE (fn); fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fn); return fold (build_call_array (TREE_TYPE (fntype), fn, nargs, CALL_EXPR_ARGP (orig_call))); } } }
int testSkipAFoldPoint(void) { char *input = "a b c de f"; char *expected = "a b.c de.f"; char output[MAXLINE] = ""; tf_assert(strcmp(fold(input, output, FOLDPOINT), expected) == 0, "Expected '%s' was '%s'", expected, output); tf_passed(); }
virtual bool updateAll() { envire::Grid<T> *inputGrid = getInput<envire::Grid<T> *>(); if(!inputGrid) throw std::runtime_error("FoldOperator: no input band set, or wrong type"); envire::Grid<T> *outputGrid = getOutput< envire::Grid<T> *>(); if (!outputGrid) throw std::runtime_error("FoldOperator: no output band set, or wrong type"); if(inputGrid->getCellSizeX() != outputGrid->getCellSizeX() || inputGrid->getCellSizeY() != outputGrid->getCellSizeY()) throw std::runtime_error("FoldOperator: Error, grids have different sizes"); typename envire::Grid<T>::ArrayType &inputData(inputGrid->getGridData()); typename envire::Grid<T>::ArrayType &outputData(outputGrid->getGridData()); maxX = inputGrid->getCellSizeX(); maxY = inputGrid->getCellSizeY(); for(size_t y = 0;y < maxY; y++) { for(size_t x = 0;x < maxX; x++) { fold(inputData, outputData, x, y); } } return true; }
namespace streams { template <class I, class F> class Fold : public Pipeable { I initial; F f; public: Fold(I &&initial, F &&f) : initial(initial), f(f) {} template <class S> auto pipe(S &&stream) const { auto init = initial; while (auto s = std::move(stream.next())) { init = f(init, *s); } return init; } }; template <class I, class F> auto fold(I &&initial, F &&f) { return Fold<I, F> {std::forward<I>(initial), std::forward<F>(f)}; } let sum = fold(0, plus); } /* streams */
double mfe_zscore(const char *seq, double mfe, int *type, int avoid_shuffle, char* warning_string) { double E, stdv, avg; char *struc; if (mfe>0) { struc = space(strlen(seq)+1); E = fold(seq, struc); free(struc); } else { E=mfe; } avg = 0.0; stdv = 0.0; predict_values(seq, &avg, &stdv, type, avoid_shuffle, warning_string); /* Just as backup strategy if something goes totally wrong, we evaluate the sequence once again by shuffling */ if (avg > -1 || stdv < 0.1) { if (*type == 2) *type = 3; if (*type == 0) *type = 1; predict_values(seq, &avg, &stdv, type, avoid_shuffle, warning_string); } /*printf("%f,%f\n",avg,stdv);*/ return ((E-avg)/stdv); }
int testEmptyInput(void) { char *input = ""; char *expected = ""; char output[MAXLINE] = ""; tf_assert(strcmp(fold(input, output, FOLDPOINT), expected) == 0, "Expected '%s' was '%s'", expected, output); tf_passed(); }
static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state, int bits) { int k, i, v, ret; i = state->count; k = 0; while (i < state->error_sum) { // FIXME: optimize k++; i += i; } v = get_sr_golomb(gb, k, 12, bits); ff_dlog(NULL, "v:%d bias:%d error:%d drift:%d count:%d k:%d", v, state->bias, state->error_sum, state->drift, state->count, k); #if 0 // JPEG LS if (k == 0 && 2 * state->drift <= -state->count) v ^= (-1); #else v ^= ((2 * state->drift + state->count) >> 31); #endif ret = fold(v + state->bias, bits); update_vlc_state(state, v); return ret; }
PRIVATE double mfe_cost(const char *string, char *structure, const char *target) { #if TDIST Tree *T1; char *xstruc; #endif double energy, distance; if (strlen(string)!=strlen(target)) { fprintf(stderr, "%s\n%s\n", string, target); nrerror("unequal length in mfe_cost"); } energy = fold(string, structure); #if TDIST if (T0 == NULL) { xstruc = expand_Full(target); T0=make_tree(xstruc); free(xstruc); } xstruc = expand_Full(structure); T1=make_tree(xstruc); distance = tree_edit_distance(T0,T1); free(xstruc); free_tree(T1); #else distance = (double) bp_distance(target, structure); #endif cost2 = energy_of_struct(string, target) - energy; return (double) distance; }