Number pre3() { Number result = pre2(); Number n; while (accept(TOKEN_MUL)) { get_token(); n = pre2(); result = big_mul(result, n); } return result; }
bool isMatch(const char *s, const char *p) { int lens = strlen(s); int lenp = strlen(p); vector<vector<bool>> dp(3, vector<bool>(lens+1, false)); dp[0][0] = true; for (int i=1; i<=lenp; i++) { dp[cur(i)][0] = i>1 && p[i-1] == '*' && dp[pre2(i)][0]; for (int j=1; j<=lens; j++) { if (p[i-1] == '*') { dp[cur(i)][j] = dp[pre2(i)][j] || ((dp[pre2(i)][j-1] || dp[cur(i)][j-1]) && isMatch(p[i-2], s[j-1])); } else { dp[cur(i)][j] = dp[pre1(i)][j-1] && isMatch(p[i-1], s[j-1]); } } } return dp[cur(lenp)][lens]; }
Number pre2() { Number result = pre1(); Number n; if (accept(TOKEN_POW)) { get_token(); n = pre2(); result = big_pow(result, get_int(n)); } return result; }
long trie_recurse( DFA<N_AMINOACIDS> &A, IDFA<int> &Apep, IDFAState<int> *pep, vector<int> &pre, const double thr_pos, int i ){ //cerr << i << " " << pre.size() << endl; if( i == pre.size() ){ IDFA<int> A2; vector<int> pre2( pre ); long snew = add_strings_near( A2, A, 0, A.pureAccepting(), pre, pre2, thr_pos, max_energy(pre), min_energy(pre), 0 ); if( snew > 0 ){ /*cout << "1st guy: " << endl; A.printDebug(); cout << "2nd guy: " << endl; DFA<N_AMINOACIDS>(A2).printDebug();*/ A = A.join( DFA<N_AMINOACIDS>(A2) ).minimize(); } //cerr << snew << endl; return snew; } long r = 0; float max_of_minima = 0.0; vector<int> dominated(N_AMINOACIDS,0); for( int j = 0 ; j < N_AMINOACIDS ; j ++ ){ if( IDFAState<int> * tgt = pep->next(aa_by_min_energy[j]) ){ pre[i] = aa_by_min_energy[j]; if( pep -> fanOut() > 1 ){ if( dominated[pre[i]] ){ continue; } for( int k = 0 ; k < N_AMINOACIDS ; k ++ ){ if( pre[i] != k && mj_domination[pre[i]][k] && ( tgt == pep->next(k) ) ){ /*cerr << aminoacids[pre[i]] << " (" << pre[i] << ") dom. " << aminoacids[k] << " (" << k << ")" << endl;*/ dominated[k]=1; } } } r += trie_recurse( A, Apep, tgt, pre, thr_pos, i+1 ); } } return r; }