double1D_ptr Polynomial::getCoef(double1D_ptr variables, const COEF & coefs) { const std::type_info & info = typeid(coefs); if (info == typeid(COEF_1)) { if (variables->dim() == 1) { return getCoef((*variables)[0], static_cast < const COEF_1 & >(coefs)); } else { return getCoef(variables, static_cast < const COEF_1 & >(coefs)); } } else if (info == typeid(COEF_3)) { return getCoef(variables, static_cast < const COEF_3 & >(coefs)); } throw java::lang::IllegalArgumentException(); };
void MMD_Polynomial::_getNormalCoef_complex( void ) { if( !term_coef.ArrayDim() ) return; MArray<UniWord> tmp( term_coef.ArrayDim(), 0, term_coef.ArrayDim() ); tmp.Copy( term_coef ); term_coef.Flush(); long i, mp; UniWord n( CDSRComplex( 0 ) ); for( i = 0; i < getMaxPow() + 1; i++ ) term_coef.Add( n ); for( i = 0; i < (long) term_pow.ArrayDim(); i++ ) _dsrop_Add_complex( term_coef[ term_pow[ i ].getInteger() ], term_coef[ term_pow[ i ].getInteger() ], tmp[ i ] ); mp = getMaxPow(); for( i = mp; i >= 0; i-- ) { UniWord uw1( CDSRInteger( 0 ) ); if( _dsrop_Equal_complex( uw1, getCoef( i ), UniWord( CDSRComplex( 0 ) ) ).getInteger() ) { term_coef.erase( term_coef.begin() + i ); mp--; } else break; } if( mp < getMaxPow() ) max_pow = mp; }
int main(int argc, char **argv) { int da = 3; int db = 3; polynomial A[5], B[5]; polynomial *C; initPoly(A, 2.0, 1000); initPoly(A+1, 1.0, 4); initPoly(A+2, 1.0, 0); initPoly(B, 10.0, 3); initPoly(B+1, 3.0, 2); initPoly(B+2, 1.0, 0); outputPoly(A, da); outputPoly(B, db); // 演示GET printf("The Max Exponent in A is %d\n", getMaxExpon(A)); printf("The Max Exponent in B is %d\n", getMaxExpon(B)); printf("The coef of Exponent %d in A is %f\n", 4, getCoef(A, 4)); printf("The coef of Exponent %d in A is %f\n",2, getCoef(B, 2)); int mult = 0; C = Mult(A, &da, B, &db, &mult); outputPoly(C, mult); /* attatch(A, &da, 4, 5); Add(A, &da, B, db); outputPoly(A, da); singleMult(A, &da, 2, 3); outputPoly(A, da); Remove(A, &da, 4); outputPoly(A, da); Remove(B, &db, 2); outputPoly(B, db); */ return 0; }
// FONCTION void NoyauPascal::calcul_taille() { int coefP = getCoef(); setTaille(1); while (coefP > 1) { coefP = (int) coefP/2; setTaille(getTaille()+1); } setTaille(getTaille()*2 - 1); }
void MatConvo::noyau_coef() { // tMilieu-1 est l'indice du coef max int tMilieu = (int) getTFiltre()/2; tMilieu++; setMat1(tMilieu-1,getCoef()); int coefP = getCoef(); // si le noyau est unique...mais il ne le devrait pas if(getTFiltre() == 1) { return; } for(int i=tMilieu-2,j=tMilieu ; i>=0 && j<getTFiltre() ; i--,j++) { coefP = (int) coefP/2; setMat1(i,coefP); setMat1(j,coefP); } }
//*************************************************************************************************************** //seqs have already been masked vector< vector<float> > DeCalculator::getQuantiles(vector<Sequence*> seqs, vector<int> windowSizesTemplate, int window, vector<float> probProfile, int increment, int start, int end) { try { vector< vector<float> > quan; //percentage of mismatched pairs 1 to 100 quan.resize(100); //for each sequence for(int i = start; i < end; i++){ m->mothurOut("Processing sequence " + toString(i)); m->mothurOutEndLine(); Sequence* query = new Sequence(seqs[i]->getName(), seqs[i]->getAligned()); //compare to every other sequence in template for(int j = 0; j < i; j++){ Sequence* subject = new Sequence(seqs[j]->getName(), seqs[j]->getAligned()); if (m->control_pressed) { delete query; delete subject; return quan; } map<int, int> trim; map<int, int>::iterator it; trimSeqs(query, subject, trim); it = trim.begin(); int front = it->first; int back = it->second; //reset window for each new comparison windowSizesTemplate[i] = window; vector<int> win = findWindows(query, front, back, windowSizesTemplate[i], increment); vector<float> obsi = calcObserved(query, subject, win, windowSizesTemplate[i]); vector<float> q = findQav(win, windowSizesTemplate[i], probProfile); float alpha = getCoef(obsi, q); vector<float> exp = calcExpected(q, alpha); float de = calcDE(obsi, exp); float dist = calcDist(query, subject, front, back); //cout << i << '\t' << j << '\t' << dist << '\t' << de << endl; dist = ceil(dist); //quanMember newScore(de, i, j); quan[dist].push_back(de); delete subject; } delete query; } return quan; } catch(exception& e) { m->errorOut(e, "DeCalculator", "getQuantiles"); exit(1); } }
float LinearAnimator::get() const { moment_t now = millis(); float coef = getCoef(); return _from + coef * (_to - _from); }
double1D_ptr Polynomial::getCoef(double1D_ptr xyz, const COEF_3 & coefs) { if (xyz->dim() != 3) { throw java::lang::IllegalArgumentException("xyz->dim() != 3"); } return getCoef((*xyz)[0], (*xyz)[1], (*xyz)[2], coefs); };