Type objective_function<Type>::operator() () { // data: DATA_MATRIX(age); DATA_VECTOR(len); DATA_SCALAR(CV_e); DATA_INTEGER(num_reads); // parameters: PARAMETER(r0); // reference value PARAMETER(b); // growth displacement PARAMETER(k); // growth rate PARAMETER(m); // slope of growth PARAMETER(CV_Lt); PARAMETER(gam_shape); PARAMETER(gam_scale); PARAMETER_VECTOR(age_re); // procedures: Type n = len.size(); Type nll = 0.0; // Initialize negative log-likelihood Type eps = 1e-5; CV_e = CV_e < 0.05 ? 0.05 : CV_e; for (int i = 0; i < n; i++) { Type x = age_re(i); if (!isNA(x) && isFinite(x)) { Type len_pred = pow(r0 + b * exp(k * x), m); Type sigma_e = CV_e * x + eps; Type sigma_Lt = CV_Lt * (len_pred + eps); nll -= dnorm(len(i), len_pred, sigma_Lt, true); nll -= dgamma(x + eps, gam_shape, gam_scale, true); for (int j = 0; j < num_reads; j++) { if (!isNA(age(j, i)) && isFinite(age(j, i)) && age(j, i) >= 0) { nll -= dnorm(age(j, i), x, sigma_e, true); } } } } return nll; }
Type objective_function<Type>::operator() () { // data: DATA_MATRIX(age); DATA_VECTOR(len); DATA_SCALAR(CV_e); DATA_INTEGER(num_reads); // parameters: PARAMETER(a); // upper asymptote PARAMETER(b); // growth range PARAMETER(k); // growth rate PARAMETER(CV_Lt); PARAMETER(beta); PARAMETER_VECTOR(age_re); // procedures: Type n = len.size(); Type nll = 0.0; // Initialize negative log-likelihood Type eps = 1e-5; CV_e = CV_e < 0.05 ? 0.05 : CV_e; for (int i = 0; i < n; i++) { Type x = age_re(i); if (!isNA(x) && isFinite(x)) { Type len_pred = a / (1 + b * exp(-k * x)); Type sigma_e = CV_e * x + eps; Type sigma_Lt = CV_Lt * (len_pred + eps); nll -= dnorm(len(i), len_pred, sigma_Lt, true); nll -= dexp(x, beta, true); for (int j = 0; j < num_reads; j++) { if (!isNA(age(j, i)) && isFinite(age(j, i)) && age(j, i) >= 0) { nll -= dnorm(age(j, i), x, sigma_e, true); } } } } return nll; }
void markOopClass::print() { lprintf("Mark#0x%lx: hash: %ld; age: %ld", this, hash(), age()); if (is_objectMarked()) lprintf("; object_is_marked"); lprintf("\n"); }
virtual std::ostream& print( std::ostream& stm = std::cout ) const { stm << name() << ' ' << age() << " years (" << faith() << ')' ; const auto f = best_friend() ; if(f) stm << " best friend: '" << f->name() << "' (" << f->faith() << ')' ; return stm << '\n' ; }
int main() { int num = age(5); printf("第5个人的年龄是%d岁", num); getchar(); return 0; }
bool Worm::tick(void) { while (true) { Position new_pos = current_pos; if (blocked || random(4) != 0) { dir = random(3); forward = (random(2) == 0); } new_pos.advance(dir, forward); if (is_empty(new_pos)) { current_pos = new_pos; cube.set_pixel(current_pos.x, current_pos.y, current_pos.z, 0xff); push(current_pos); tries += IQ; blocked = false; } else { blocked = true; tries++; } if (tries >= IQ) { age(); tries = 0; return false; } } }
/** * Function: Keyboard commands */ void keyboard(unsigned char key, int x, int y) { switch (key) { case 'q': exit(0); break; case ' ': age(); break; case 'c': counting = !counting; break; case 'r' : autoUpdate = 1; autoAge(1); break; case 'e' : autoUpdate = 0; break; case 'h': printCommands(); return; default: break; } glutPostRedisplay(); }
int age(int n) { if (n==1) return 10; else return age(n-1)+2; }
void Block::onUpdate(float elapsedSeconds) { UNUSED(elapsedSeconds); mSprite.setPosition(Game::Scale * mBody->GetPosition().x, Game::Scale * mBody->GetPosition().y); mSprite.setRotation(rad2deg(mBody->GetAngle())); if (gLocalSettings().useShaders()) mShader.setParameter("uAge", age().asSeconds()); }
/** * Function: Uses timer callback to run while autoUpdate is true */ void autoAge(int i) { age(); if(autoUpdate) { glutTimerFunc(500, autoAge, i); } glutPostRedisplay(); }
int main() { int age(int c); int num; printf("input age:"); scanf("%d",&num); printf("NO.5 number is %d\n",age(num)); return 0; }
int age(int c) { int number; if(c==1){ number=10; }else{ number = age(c-1) + 2; } return number; }
int isOlder(char *dob1, char *dob2) { int n, m; long valp = 0, valq = 0; n = strlen(dob1); m = strlen(dob2); if ((n != 10) || (m != 10)) return -1; valp = age(dob1); valq = age(dob2); if ((valp == -1) || (valq == -1)) return -1; if (valp < valq) return 1; else if (valp > valq) return 2; else return 0; }
//------------------------------------------------------------------------------ // Class: Particle // Method: update // Description: //------------------------------------------------------------------------------ void Particle::update(Real theElapsedTime) { age(theElapsedTime); if( isAlive() ) { mPosition += mLinearVelocity * theElapsedTime; mAngle += mAngularVelocity * theElapsedTime; } }
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC void markOopDesc::print_on(outputStream* st) const { if (is_marked()) { st->print(" marked(" INTPTR_FORMAT ")", value()); } else if (has_monitor()) { // have to check has_monitor() before is_locked() st->print(" monitor(" INTPTR_FORMAT ")=", value()); ObjectMonitor* mon = monitor(); if (mon == NULL) { st->print("NULL (this should never be seen!)"); } else { st->print("{count=" INTPTR_FORMAT ",waiters=" INTPTR_FORMAT ",recursions=" INTPTR_FORMAT ",owner=" INTPTR_FORMAT "}", mon->count(), mon->waiters(), mon->recursions(), p2i(mon->owner())); } } else if (is_locked()) { st->print(" locked(" INTPTR_FORMAT ")->", value()); if (is_neutral()) { st->print("is_neutral"); if (has_no_hash()) { st->print(" no_hash"); } else { st->print(" hash=" INTPTR_FORMAT, hash()); } st->print(" age=%d", age()); } else if (has_bias_pattern()) { st->print("is_biased"); JavaThread* jt = biased_locker(); st->print(" biased_locker=" INTPTR_FORMAT, p2i(jt)); } else { st->print("??"); } } else { assert(is_unlocked() || has_bias_pattern(), "just checking"); st->print("mark("); if (has_bias_pattern()) st->print("biased,"); st->print("hash %#lx,", hash()); st->print("age %d)", age()); } }
void Entity::postUpdate() { setHydration(getHydration() - (20 * getHeatLevel())); if (getHydration() <= 100) { takeEnergy(2.0 * (1.0 + 100.0 / age())); } else { takeEnergy(1.0 * (1.0 + 100.0 / age())); } if (getEnergy() <= 0.1) { takeHealth(2); } if (getHydration() <= 0.1) { takeHealth(2); } }
void markOopDesc::print_on(outputStream* st) const { if (is_locked()) { st->print("locked(0x%lx)->", value()); markOop(*(markOop*)value())->print_on(st); } else { assert(is_unlocked(), "just checking"); st->print("mark("); st->print("hash %#lx,", hash()); st->print("age %d)", age()); } }
//------ Begin of function Faculty::disp_summary_basic -------// //! void Faculty::disp_summary_basic(int x, int y, int xColumn2, int refreshFlag, int displayModeFlag) { int x2=x+97; //--------------- display fields -----------// font_chartsm.field( x, y , "Name" , x2, name(), xColumn2-1, refreshFlag ); font_chartsm.field( x, y+17, "Gender/ethnicity", x2, game_str_res.gender_ethnic_str(gender_ethnic_group), xColumn2-1, refreshFlag ); font_chartsm.field( x, y+34, "Age" , x2, age(), 1, xColumn2-1, refreshFlag ); font_chartsm.field( x, y+51, "Rank" , x2, game_str_res.rank_str(rank_level), xColumn2-1, refreshFlag ); x =xColumn2; x2=x+162; font_chartsm.field( x, y , "Salary" , x2, salary, 2, REPORT_X2-30, refreshFlag ); // font_chartsm.field( x, y+17, "Employed period" , x2, employed_period(), REPORT_X2-30, refreshFlag ); if ( displayModeFlag ) { char employStr[123]; if ( employ_status == 0 ) strcpy(employStr,"0 years"); else strcpy(employStr,employed_period()); font_chartsm.field( x, y+17, "Time in rank" , x2, employStr, REPORT_X2-30, refreshFlag ); } else font_chartsm.field( x, y+17, "Time in rank" , x2, employed_period(), REPORT_X2-30, refreshFlag ); if ( displayModeFlag ) { char statusStr[123]; switch(employ_status) { case 0: strcpy(statusStr,"New hire"); break; case 1: strcpy(statusStr,"Departure"); break; case 2: strcpy(statusStr,"Promotion"); break; default: strcpy(statusStr,""); } font_chartsm.field( x, y+34, "Status change", x2, statusStr, REPORT_X2-30, refreshFlag ); } else font_chartsm.field( x, y+34, "Off-duty trimester", x2, game_str_res.trimester_str(off_duty_trimester), REPORT_X2-30, refreshFlag ); font_chartsm.field( x, y+51, "Satisfaction index", x2, (int) satisfaction_index, 3, REPORT_X2-30, refreshFlag ); if( faculty_res.report_type==REPORT_TYPE_LIST) { x2+=140; int h1,h2,h3; h1=(int)(21*performance_teaching/100); h2=(int)(21*performance_scholarship/100); h3=(int)(21*performance_research/100); vga_back.bar(x2-1,y+62-h3-h2-h1,x2+13,y+64,V_BLACK); vga_back.v_indicator(x2, y+63-h3-h2-h1, x2+12, y+63-h3-h2, performance_teaching, performance_teaching, VGA_RED ); vga_back.v_indicator(x2, y+63-h3-h2, x2+12, y+63-h3, performance_scholarship, performance_scholarship, VGA_YELLOW ); vga_back.v_indicator(x2, y+63-h3, x2+12, y+63, performance_research, performance_research, VGA_SEA_GREEN ); } }
int age(int n) { int num; if (n == 1) { return 10; } else { num = age(n - 1) + 2; } return num; }
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC void markOopDesc::print_on(outputStream* st) const { if (is_locked()) { st->print("locked(" INTPTR_FORMAT ")->", value()); markOop(*(markOop*)value())->print_on(st); } else { assert(is_unlocked() || has_bias_pattern(), "just checking"); st->print("mark("); if (has_bias_pattern()) st->print("biased,"); st->print("hash %#lx,", hash()); st->print("age %d)", age()); } }
int calcMoveBase(CharData *ch) { int base = 0; base += graf(age(ch).year, 40, 39, 34, 30, 26, 24, 23); /* Class/Level calculations */ if (GET_CLASS(ch) == CLASS_RANGER) base += GET_LEVEL(ch); else if (GET_CLASS(ch) == CLASS_ASSASSIN || GET_CLASS(ch) == CLASS_THIEF) base += GET_LEVEL(ch)*2/3; else base += GET_LEVEL(ch)/3; return base; }
// -------------------------------------------- void ofSkeleton::draw(float x, float y, float w, float h, float d) { if(age() < 2) frame.draw(x, y, w, h, d); // Draw particles for(int i=0; i<particles.size(); i++) { ofSetColor(particles[i].color); ofPushMatrix(); ofTranslate(particles[i].x*w, particles[i].y*h, particles[i].z*d); ofCircle(0, 0, particles[i].radius); ofPopMatrix(); } }
void quasiUniqueQ::enqueue(int num) { if (filter(num)) { if (index == size) resize(); index++; int position = index; array[index].data = num; array[index].age = 0; while (position > 1 && array[position].data - array[position].age <= array[position/2].data - array[position/2].age) { swap(array[position], array[position/2]); position = position/2; } age(); } }
int main(void) { FILE *file; int switchRun; int endRequested = 0; struct person *list = NULL; file = fopen(FILENAME, "r"); if (file == NULL) { perror("Cant read file"); return 1; } list = loadFromFile(file); printf("- LOADED ---------------------\n"); printPersons(list); while (endRequested == 0) { printf("- MENU ---------------------\n"); printf("[1] - addPerson\n"); printf("[2] - deletePerson\n"); printf("[3] - age\n"); printf("[4] - city == 'Presov'\n"); printf("other - close\n"); scanf("%d", &switchRun); switch (switchRun) { case 1 : list = addPerson(list); break; case 2 : list = delPerson(list); break; case 3 : age(list); break; case 4 : city(list, "Presov"); break; default: endRequested = 1; } } freeItems(list); return 0; }
bool RandomMovementParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps) { //System->setUpdateSecAttribs(false); Real32 x, y, z, age(System->getAge(ParticleIndex)); if(getAttributeAffected() == VELOCITY_ATTRIBUTE) { Vec3f vel = System->getSecVelocity(ParticleIndex); // grab each value independently , and adjust the phase for each // axis, since we have a 3D phase and the 1D distribution only takes // one value Real32 velSum = vel.x() + vel.y() + vel.z(); getPerlinDistribution()->setPhase(getPhase().x() + velSum); x = getPerlinDistribution()->generate(vel.x() + age); getPerlinDistribution()->setPhase(getPhase().y() + velSum); y = getPerlinDistribution()->generate(vel.y() + age); getPerlinDistribution()->setPhase(getPhase().z() + velSum); z = getPerlinDistribution()->generate(vel.z() + age); System->setVelocity(Vec3f(x,y,z) + vel,ParticleIndex); }else // affecting position { Pnt3f pos = System->getSecPosition(ParticleIndex); Real32 posSum = pos.x() + pos.y() + pos.z(); getPerlinDistribution()->setPhase(getPhase().x() + posSum); x = getPerlinDistribution()->generate(pos.x() + age); getPerlinDistribution()->setPhase(getPhase().y() + posSum); y = getPerlinDistribution()->generate(pos.y() + age); getPerlinDistribution()->setPhase(getPhase().z() + posSum); z = getPerlinDistribution()->generate(pos.z() + age); System->setPosition(Pnt3f(x,y,z) + pos.subZero(),ParticleIndex); } return false; }
/* Hitpoint gain pr. game hour */ int hit_gain(struct char_data * ch) { int gain; if (IS_NPC(ch)) { /* Neat and fast */ gain = GET_LEVEL(ch); } else { gain = graf(age(ch)->year, 8, 12, 20, 32, 16, 10, 4); /* Class/Level calculations */ /* Skill/Spell calculations */ /* Position calculations */ switch (GET_POS(ch)) { case POS_SLEEPING: gain += (gain / 2); /* Divide by 2 */ break; case POS_RESTING: gain += (gain / 4); /* Divide by 4 */ break; case POS_SITTING: gain += (gain / 8); /* Divide by 8 */ break; } if (IS_MAGIC_USER(ch) || IS_CLERIC(ch)) gain /= 2; /* Ouch. */ if ((GET_COND(ch, FULL) == 0) || (GET_COND(ch, THIRST) == 0)) gain /= 4; } if (AFF_FLAGGED(ch, AFF_POISON)) gain /= 4; return (gain); }
int calcHitBase(CharData *ch) { int base = 0; if(IS_NPC(ch)) base += 18; else { base += graf(age(ch).year, 37, 38, 43, 46, 40, 34, 32); } /* Level/Class bonuses */ switch(GET_CLASS(ch)) { case CLASS_WARRIOR: base += GET_LEVEL(ch)*5/3; break; case CLASS_RANGER: case CLASS_SOLAMNIC_KNIGHT: case CLASS_DEATH_KNIGHT: base += GET_LEVEL(ch)*4/3; break; case CLASS_THIEF: case CLASS_ASSASSIN: base += GET_LEVEL(ch); break; case CLASS_SHOU_LIN: case CLASS_CLERIC: case CLASS_SHADOW_DANCER: base += GET_LEVEL(ch)*2/3; break; case CLASS_MAGIC_USER: case CLASS_NECROMANCER: base += GET_LEVEL(ch)/3; break; default: mudlog(NRM, LVL_IMMORT, TRUE, "ERROR calcManaBase: %s's class not recognized!", GET_NAME(ch)); break; } if(affected_by_spell(ch, SKILL_ADRENALINE)) { struct affected_type *af; for (af = ch->affected; af; af = af->next) { if(af->type == SKILL_ADRENALINE) base += af->modifier; } } /* Position calculations */ switch (GET_POS(ch)) { case POS_MEDITATING: if(IS_CHI_WARRIOR(ch) && GET_ADVANCE_LEVEL(ch) >= SECOND_ADVANCE_SKILL) base += GET_LEVEL(ch)/10; case POS_SLEEPING: base += 20; /* Divide by 2 */ break; case POS_RESTING: base += 12; /* Divide by 4 */ break; } // Naturalist hunters get 1% bonus regen to pets per advance level. if (affected_by_spell(ch, SPELL_CALL_OF_THE_WILD) && ch->master && IS_NATURALIST(ch->master)) base += GET_MAX_HIT(ch)*GET_ADVANCE_LEVEL(ch->master)/100; return base; }
int calcManaBase(CharData *ch) { int base = 0; /* Set base regeneration */ if (IS_NPC(ch)) { base += GET_LEVEL(ch) * 2; } else { base += graf(age(ch).year, 34, 32, 24, 26, 30, 41, 42); /* Class bonuses */ switch(GET_CLASS(ch)) { case CLASS_MAGIC_USER: case CLASS_NECROMANCER: base += GET_LEVEL(ch); break; case CLASS_CLERIC: case CLASS_SHADOW_DANCER: base += GET_LEVEL(ch)*2/3; break; case CLASS_SOLAMNIC_KNIGHT: case CLASS_DEATH_KNIGHT: base += GET_LEVEL(ch)/2; break; case CLASS_SHOU_LIN: case CLASS_RANGER: base += GET_LEVEL(ch)/3; break; case CLASS_WARRIOR: case CLASS_THIEF: case CLASS_ASSASSIN: break; default: mudlog(NRM, LVL_IMMORT, TRUE, "ERROR calcManaBase: %s's class not recognized!", GET_NAME(ch)); break; } /* Race bonuses*/ if(IS_DROW(ch)) base += (GET_LEVEL(ch)/8); /* Position calculations */ switch (GET_POS(ch)) { case POS_MEDITATING: if(IS_CHI_WARRIOR(ch) && GET_ADVANCE_LEVEL(ch) >= SECOND_ADVANCE_SKILL) base += GET_LEVEL(ch)/10; case POS_SLEEPING: base += 16; break; case POS_RESTING: base += 8; /* Divide by 2 */ break; } } /* Int/wis bonus */ base += (GET_WIS(ch) + GET_INT(ch) - 30); if(!IS_NPC(ch) && IS_VAMPIRE(ch) && IS_SUNLIGHT(IN_ROOM(ch)) && !IS_AFFECTED(ch, AFF_SHADOW_SPHERE)) base = 0; return base; }
void MainDlg::OnLbnSelchangeUserList() { int curindex = _userList.GetCurSel(); if( curindex >= 0 ) { int userNo = (int)_userList.GetItemData( curindex ); UserList & userInfoList = Network::GetInstance().GetUserInfoList(); int index = Network::GetInstance().GetIndexForUserNo( userNo ); UserInfo & userInfo = userInfoList[ index ]; std::string picPath = "../Test/pic/" + userInfo._pic; CString age( userInfo._age.c_str() ); CString sex( userInfo._sex.c_str() ); CString tall( userInfo._tall.c_str() ); CString weight( userInfo._weight.c_str() ); CString blood( userInfo._blood.c_str() ); CString tel( userInfo._tel.c_str() ); CString pic( picPath.c_str() ); _userDataList.DeleteAllItems(); LV_ITEM lvItem; CString itemText; itemText = "나이"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 0; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)age; _userDataList.SetItem(&lvItem); itemText = "성별"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 1; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 1; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)sex; _userDataList.SetItem(&lvItem); itemText = "키"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 2; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 2; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)tall; _userDataList.SetItem(&lvItem); itemText = "몸무게"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 3; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 3; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)weight; _userDataList.SetItem(&lvItem); itemText = "혈액형"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 4; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 4; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)blood; _userDataList.SetItem(&lvItem); itemText = "전화"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 5; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 5; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)tel; _userDataList.SetItem(&lvItem); HBITMAP hBmp = (HBITMAP)LoadImage(NULL, pic, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); _image.SetBitmap( hBmp ); // m_wndView->SetUserNo( userNo ); // OnCbnSelchangeComboHour(); } }
int main(int argc, char *argv[]) { printf("The 5th people's age is: %d\n", age(5)); return 0; }