void updatePMLEFieldUtilEx(int xStart, int xEnd, int yStart, int yEnd, int zStart, int zEnd, int xBound, int yBound, int zBound, pmlConstStruct cx[], pmlConstStruct cy[], pmlConstStruct cz[], int n){ int i, j, k; // These are the indexes int x,y,z;// There are indexes for the pmlConstStruct indexs long p; int m; double dxStore; double eps; for (i=xStart;i<xEnd+1;i++){ x = abs(xBound - i)%PML_LAYERS; for (j=yStart;j<yEnd+1;j++){ y = abs(yBound - j)%PML_LAYERS; for (k=zStart;k<zEnd+1;k++){ z = abs(zBound - k)%PML_LAYERS; p = PMLINDEX(i,j,k); dxStore = DX(p); m = MATERIALINDEX(i,j,k); eps = EPSR(m)*EPSNOT; DX(p) = cy[y].c1*DX(p) + cy[y].c2*(HZ(i,j,k) - HZ(i,j-1,k) - HY(i,j,k) + HY(i,j,k-1) - JSX(m)); EX(i,j,k) = cz[z].c3*EX(i,j,k) + cz[z].c4*(cx[x].c5*DX(p)-cx[x].c6*dxStore)/eps; }}} // end for }// end updatePMLEFieldUtilEx
void LevelWinDialog::paintContent(QPainter &p) { GamePanel::paintContent(p); p.setOpacity(1); p.setFont(gameStock->Font40); p.setPen(QPen(QColor(0x030055))); drawHCentered(p, 50, tr("Level %1 completed!").arg(level)); p.setFont(gameStock->Font20); const int y30 = DY(40); const int x1 = DX(300), x2 = DX(380), x3 = DX(600); const int y1 = DY(250), y2 = DY(350); p.drawPixmap(x1,y1, gameStock->Clock); p.drawText(x3,y1+y30, QString("%1:%2").arg(time/60, 2, 10, QChar('0')).arg(time%60, 2, 10, QChar('0'))); p.drawPixmap(x1,y2, gameStock->Score); p.drawText(x3,y2+y30, QString::number(score)); p.setPen(QPen(Qt::black)); p.drawText(x2,y1+y30, tr("Time left:")); p.drawText(x2,y2+y30, tr("Score:")); }
static int mainloop(struct cfg_s *c) { int i; struct mbuf *m; for (i=0; i < c->loops; i++) { /* implement histeresis */ controller(c); DX(3, "loop %d enq %d send %p rx %d", i, c->_enqueue, c->tosend, c->can_dequeue); if ( (m = c->tosend) ) { c->_enqueue++; if (enqueue(c, m)) { drop(c, m); ND("loop %d enqueue fail", i ); } else { ND("enqueue ok"); c->pending++; } } if (c->can_dequeue) { c->dequeue++; if ((m = dequeue(c))) { c->pending--; drop(c, m); c->drop--; /* compensate */ } } } DX(1, "mainloop ends %d", i); return 0; }
void GameWinDialog::paintContent(QPainter &p) { GamePanel::paintContent(p); p.setOpacity(1); p.setFont(gameStock->Font60); p.setPen(QPen(QColor(0x030055))); drawHCentered(p, 50, tr("You're the Winner!")); p.setFont(gameStock->Font40); drawHCentered(p, 200, tr("You finished all the levels!")); p.setFont(gameStock->Font20); const int y30 = DY(40); const int x1 = DX(300), x2 = DX(420), x3 = DX(600); const int /*y1 = DY(250), */y2 = DY(350)/*, y3 = DY(350)*/; p.drawPixmap(x1,y2, gameStock->Score); p.drawText(x3,y2+y30, QString::number(score)); p.setPen(QPen(Qt::black)); p.drawText(x2,y2+y30, tr("Score:")); }
button * add_button(Rectangle r, char *name, char *default_label, Pixel color, void *param) { button *b = (button *)malloc(sizeof(button)); utf8 *label[bstates]; assert(b); // allocating button memory b->type = Button; b->r = r; b->name = name; b->state = default_button_state; b->next = 0; b->param = param; b->category = default_category; last_button = b; if ( !(ptinrect(r.min, screen_rect) && r.max.x <= screen_rect.max.x && r.max.y <= screen_rect.max.y)) { fprintf(stderr, "*** button %s is off screen, ignored: %d,%d - %d,%d\n", name, r.min.x, r.min.y, r.max.x, r.max.y); return 0; } /* lookup configuration file alternates for our default label names. */ label[Off] = lookup(name, ".off", default_label); label[On] = lookup(name, ".on", default_label); label[Unavailable] = lookup(name, ".unavail", default_label); fprintf(stderr, "0 "); make_PixMap(&b->pm[Off], (Rectangle){{0,0},{DX(r),DY(r)}}, color); fprintf(stderr, "1 "); make_PixMap(&b->pm[On], (Rectangle){{0,0},{DX(r),DY(r)}}, color); fprintf(stderr, "1 "); make_PixMap(&b->pm[Unavailable],(Rectangle){{0,0},{DX(r),DY(r)}}, dim_color(color)); fprintf(stderr, "2\n"); b_fill_rect(b->pm[Off], inset(b->pm[Off].r, BUTTON_RIM), dim_color(color)); b_fill_rect(b->pm[On], inset(b->pm[On].r, BUTTON_RIM), Black); string_on_pixmap(&(b->pm[Off]), label[Off], White, 1, 1); string_on_pixmap(&(b->pm[On]), label[On], White, 1, 1); string_on_pixmap(&(b->pm[Unavailable]), label[Unavailable], dim_color(White), 1, 1); /* Add button to the end of the linked list */ fprintf(stderr, "2 "); if (buttons == 0) buttons = b; else { button *bp = buttons; while (bp->next) bp = bp->next; bp->next = b; } return b; }
int main(int ac, char *av[]) { struct cfg_s c; struct timeval end; double ll; int i; char msg[40]; uint64_t cyc; struct sched_param schedparam; schedparam.sched_priority = 11; if (sched_setscheduler(0, SCHED_FIFO, &schedparam) == 0) printf("Set process to real-time priority %i\n", 11); else printf("Couldn't invoke real time scheduling priority %i" " (access denied?)\n", 11); bzero(&c, sizeof(c)); c.ac = ac; c.av = av; init(&c); gettimeofday(&c.time, NULL); cyc = mainloop(&c); gettimeofday(&end, NULL); end.tv_sec -= c.time.tv_sec; end.tv_usec -= c.time.tv_usec; if (end.tv_usec < 0) { end.tv_usec += 1000000; end.tv_sec--; } c.time = end; ll = end.tv_sec*1000000 + end.tv_usec; ll *= 1000; /* convert to nanoseconds */ ll /= c._enqueue; sprintf(msg, "1::%d", c.flows); D("%-8s n %d %d time %d.%06d %8.3f qlen %d %d flows %s drops %d", c.name, c._enqueue, c.loops, (int)c.time.tv_sec, (int)c.time.tv_usec, ll, c.th_min, c.th_max, c.fs_config ? c.fs_config : msg, c.drop); D("---Accurate Timing Information---"); D("Time for Cycle:\n\t Originally:%8.3f ns\n\tWith gticks:%8.3f ns\n", ll, (double) cyc2ns(cyc) / c._enqueue); D("Summary time:\n\t Originally: %d.%06d s\n\tWith gticks: %8.6f s\n", (int)c.time.tv_sec, (int)c.time.tv_usec, (double) cyc2ns(cyc)/1000000000.0); dump(&c); DX(1, "done ac %d av %p", ac, av); for (i=0; i < ac; i++) DX(1, "arg %d %s", i, av[i]); return 0; }
static void request_move_right(void) { if (y < NAMES_PER_COL(page) - 1 && PXY2N(page,0,y+1) < rl.cur_entries && (x == NAMES_PER_LINE(page) - 1 || PXY2N(page,x+1,y) > rl.cur_entries -1) ) { request_move_to_sol(); request_move_down(); } else if (y == NAMES_PER_COL(page) - 1 && x == NAMES_PER_LINE(page) - 1 && PXY2N(page+1,0,0) < rl.cur_entries) { normalize(PXY2N(page+1,0,0)); } else if (PXY2N(page,x,y) + DX(page) < rl.cur_entries ) { normalize(PXY2N(page,x,y) + DX(page)); } }
int dump(struct cfg_s *c) { int i; struct dn_queue *q; for (i=0; i < c->flows; i++) { q = FI2Q(c, i); DX(1, "queue %4d tot %10lld", i, q->ni.tot_bytes); } DX(1, "done %d loops\n", c->loops); return 0; }
/* * The controller decides whether in this iteration we should send * (the packet is in c->tosend) and/or receive (flag c->can_dequeue) */ static void controller(struct cfg_s *c) { struct mbuf *m; struct dn_fs *fs; int flow_id; /* histeresis between max and min */ if (c->state == 0 && c->pending >= c->th_max) c->state = 1; else if (c->state == 1 && c->pending <= c->th_min) c->state = 0; ND(1, "state %d pending %2d", c->state, c->pending); c->can_dequeue = c->state; c->tosend = NULL; if (c->state) return; if (1) { int i; struct dn_queue *q; struct list_head *h; i = ffs(c->llmask) - 1; if (i < 0) { DX(2, "no candidate"); c->can_dequeue = 1; return; } h = &c->ll[i]; ND(1, "backlog %d p %p prev %p next %p", i, h, h->prev, h->next); q = list_first_entry(h, struct dn_queue, ni.h); list_del(&q->ni.h); flow_id = Q2FI(c, q); DX(2, "extracted flow %p %d backlog %d", q, flow_id, i); if (list_empty(h)) { ND(2, "backlog %d empty", i); c->llmask &= ~(1<<i); } ND(1, "before %d p %p prev %p next %p", i+1, h+1, h[1].prev, h[1].next); list_add_tail(&q->ni.h, h+1); ND(1, " after %d p %p prev %p next %p", i+1, h+1, h[1].prev, h[1].next); if (i < BACKLOG) { ND(2, "backlog %d full", i+1); c->llmask |= 1<<(1+i); } fs = &q->fs->fs; c->cur_fs = q->fs - c->fs; fs->cur = flow_id; } else {
void IScene::addTime(int timeAdd) { time += timeAdd; createStaticPopup(QRect(DX(975), DY(75), DX(100), DY(30)), QString("+%1").arg(timeAdd), Qt::AlignLeft | Qt::AlignTop, gameStock->Font20, Qt::yellow, 1, 0, 20, 0, -1 ); }
static void dump_assertion_type_value (gulong type) { switch (type) { #define DX(x) case x: g_printerr ("%s", #x); break; DX(CKT_X_DISTRUSTED_CERTIFICATE); DX(CKT_X_PINNED_CERTIFICATE); DX(CKT_X_ANCHORED_CERTIFICATE); #undef DX default: g_printerr ("%u", (unsigned int)type); break; } }
void Scene::drawTextHint(QPainter& painter) { painter.setOpacity(1); painter.setPen(QPen(Qt::white)); painter.setFont(gameStock->font12); QString hintText = "Hint"; painter.drawText(0, DY(690), DX(860), DY(30), Qt::AlignRight, hintText); }
void freeDOS (short sel) { AX(regs) = 0x0101; // DPMI free DOS memory DX(regs) = sel; int386( DPMI_INT, ®s, ®s); }
void far *allocDOS (unsigned nbytes, short *pseg, short *psel) { unsigned npara = (nbytes + 15) / 16; void far *pprot; pprot = NULL; *pseg = 0; // assume will fail *psel = 0; // DPMI call 100h allocates DOS memory segread (&sregs); AX (regs) = 0x0100; // DPMI: Allocate DOS Memory BX (regs) = npara; // number of paragraphs to alloc int386( DPMI_INT, ®s, ®s); if (regs.w.cflag == 0) { *pseg = AX (regs); // the real-mode segment *psel = DX (regs); // equivalent protected-mode selector // pprot is the protected mode address of the same allocated block. // The Rational extender maps the 1 MB physical DOS memory into // the bottom of our virtual address space. pprot = (void far *) ((unsigned)*pseg << 4); } return pprot; }
void show_hist(void) { int i, y; int font_height = FONTHEIGHT(text_font); Point p = (Point){hist_r.min.x, hist_r.max.y}; struct button_info *bi = 0; clear_to_background(hist_r); for (i=0; i<nhist; i++) { button *bp = history[i]; bi = (struct button_info *)bp->param; p.y -= 2; p.y -= DY(bi->name.r); write_pixmap(p, bi->name.r, bi->name); } #ifdef explain clear_to_background(explain_r); if (nhist) { if (DX(bi->description.r)) write_pixmap(explain_r.min, bi->description.r, bi->description); else write_pixmap(explain_r.min, bi->name.r, bi->name); } #endif }
// update value in dialog void DTransformPosition::SetValue(const char *value) { CDataExchange DX(this,FALSE); m_value = value; DDX_Text(&DX, IDC_VALUE, m_value); }
// update value in dialog void GTransformPathHandler::UpdateDialogValue(const char *value) { CDataExchange DX(dialog,FALSE); dialog->m_value = value; DDX_Text(&DX, IDC_VALUE, dialog->m_value); }
/* interpret a number in human form */ static long getnum(const char *s, char **next, const char *key) { char *end = NULL; long l; if (next) /* default */ *next = NULL; if (s && *s) { DX(3, "token is <%s> %s", s, key ? key : "-"); l = strtol(s, &end, 0); } else { DX(3, "empty string"); l = -1; } if (l < 0) { DX(2, "invalid %s for %s", s ? s : "NULL", (key ? key : "") ); return 0; // invalid } if (!end || !*end) return l; if (*end == 'n') l = -l; /* multiply by n */ else if (*end == 'K') l = l*1000; else if (*end == 'M') l = l*1000000; else if (*end == 'k') l = l*1024; else if (*end == 'm') l = l*1024*1024; else if (*end == 'w') ; else {/* not recognized */ D("suffix %s for %s, next %p", end, key, next); end--; } end++; DX(3, "suffix now %s for %s, next %p", end, key, next); if (next && *end) { DX(3, "setting next to %s for %s", end, key); *next = end; } return l; }
template<> Vec<3,Float> VecBase<Vec<3,Float>>::normalize(option<Real&> len) const { if (len) { Real l = length(); if (l > RealT::zeroTol) { len = l; return *this / l; } len = 0; return VecS().fromZero(); } VecS ret; D3DXVec3Normalize(DX(ret), DX(*this)); return ret; };
static void request_move_left(void) { if ( x == 0 && y + page > 0 ) { request_move_up(); request_move_to_eol(); } else { normalize(PXY2N(page,x,y) - DX(page)); } }
/* * Return a button's rectangle the same size and shape as the given rectangle, * just to the right of it. */ Rectangle right(Rectangle br) { Rectangle r; r.min.x = br.max.x + button_sep; r.max.x = r.min.x + DX(br); r.max.y = br.max.y; r.min.y = br.min.y; return r; }
void DTransformNewObject::OnShare() { CDataExchange DX(this,TRUE); DDX_Check(&DX, IDC_SHARE, m_share); GNewObjectHandler *h= (GNewObjectHandler *) m_handler; if (!h) return; h->copyObject = !m_share; }
void CErrorAnal_dlg::UpdateStatParams() { CDataExchange DX(this,FALSE); DDX_Text(&DX, IDC_NUM_FEATR, m_num_featr); DDX_Text(&DX, IDC_RAW_ERR, m_raw_error); DDX_Text(&DX, IDC_RESID_ERR, m_resid_error); DDX_Text(&DX, IDC_BIAS, m_bias); if (m_separam && m_mahal>=0) DDX_Text(&DX, IDC_MAHAL, m_mahal); else GetDlgItem(IDC_MAHAL)->SetWindowText(""); }
static inline void calcE(void) { for(int i=1; i<N_PX-1; i++) for(int j=1; j<N_PY-1; j++) Ex[ind(i,j)] = DX(i,j)/EPSEX(i,j); for(int i=1; i<N_PX-1; i++) for(int j=1; j<N_PY-1; j++) Ey[ind(i,j)] = DY(i,j)/EPSEY(i,j); }
/* * Paint the button. If it is hidden, blacken the area. If they don't want us * to blacken the area, they shouldn't call us in the first place. */ void paint_button(button *b) { assert(b->state >= 0 && b->state < bstates); if (b->state == Hidden) { fill_rect(b->r, Black); return; } write_pixmap(b->r.min, (Rectangle){{0,0}, {DX(b->pm[b->state].r),DY(b->pm[b->state].r)}}, b->pm[b->state]); }
int main(int ac, char *av[]) { struct cfg_s c; struct timeval end; double ll; int i; char msg[40]; bzero(&c, sizeof(c)); c.ac = ac; c.av = av; init(&c); gettimeofday(&c.time, NULL); mainloop(&c); gettimeofday(&end, NULL); end.tv_sec -= c.time.tv_sec; end.tv_usec -= c.time.tv_usec; if (end.tv_usec < 0) { end.tv_usec += 1000000; end.tv_sec--; } c.time = end; ll = end.tv_sec*1000000 + end.tv_usec; ll *= 1000; /* convert to nanoseconds */ ll /= c._enqueue; sprintf(msg, "1::%d", c.flows); D("%-8s n %d %d time %d.%06d %8.3f qlen %d %d flows %s drops %d", c.name, c._enqueue, c.loops, (int)c.time.tv_sec, (int)c.time.tv_usec, ll, c.th_min, c.th_max, c.fs_config ? c.fs_config : msg, c.drop); dump(&c); DX(1, "done ac %d av %p", ac, av); for (i=0; i < ac; i++) DX(1, "arg %d %s", i, av[i]); return 0; }
void updatePMLEFieldUtilAll(int xStart, int xEnd, int yStart, int yEnd, int zStart, int zEnd, int xBound, int yBound, int zBound, pmlConstStruct cx[], pmlConstStruct cy[], pmlConstStruct cz[], int n){ int i, j, k; // These are the indexes int x,y,z;// There are indexes for the pmlConstStruct indexs long p; int m; double dxStore, dyStore, dzStore; double eps; // Either this, or make cOnes a bigger array with number of elements which are the max of xLen, yLen, zLen for (i=xStart;i<xEnd+1;i++){ x = abs(xBound - i)%PML_LAYERS; for (j=yStart;j<yEnd+1;j++){ y = abs(yBound - j)%PML_LAYERS; for (k=zStart;k<zEnd+1;k++){ z = abs(zBound - k)%PML_LAYERS; //printf("(i,j,k) (%d, %d, %d), (x,y,z) (%d,%d,%d)\n", i,j,k,x,y,z); p = PMLINDEX(i,j,k); dxStore = DX(p); dyStore = DY(p); dzStore = DZ(p); m = MATERIALINDEX(i,j,k); eps = EPSR(m)*EPSNOT; DX(p) = cy[y].c1*DX(p) + cy[y].c2*(HZ(i,j,k) - HZ(i,j-1,k) - HY(i,j,k) + HY(i,j,k-1) - JSX(m)); EX(i,j,k) = cz[z].c3*EX(i,j,k) + cz[z].c4*(cx[x].c5*DX(p)-cx[x].c6*dxStore)/eps; DY(p) = cz[z].c1*DY(p) + cz[z].c2*(HX(i,j,k) - HX(i,j,k-1) + HZ(i-1,j,k) - HZ(i,j,k) - JSY(m)); EY(i,j,k) = cx[x].c3*EY(i,j,k) + cx[x].c4*(cy[y].c5*DY(p)-cy[y].c6*dyStore)/eps; DZ(p) = cx[x].c1*DZ(p) + cx[x].c2*(HY(i,j,k) - HY(i-1,j,k) - HX(i,j,k) + HX(i,j-1,k) - JSZ(m)); EZ(i,j,k) = cy[y].c3*EZ(i,j,k) + cy[y].c4*(cz[z].c5*DZ(p)-cz[z].c6*dzStore)/eps; }}} // end for }// end updatePMLEFieldUtilAll
//-------------------------------------------------------------------// // OnSelchangeDatetimeCalendar() // //-------------------------------------------------------------------// // Update from calendar to selector. // // NOTE: This notification message is similar to MCN_SELECT, but // it is sent in response to any selection change. MCN_SELECT is // sent only for an explicit date selection. For example, the // control sends MCN_SELCHANGE when the user explicitly changes // his or her selection within the current month or when the // selection is implicitly changed in response to next/previous // month navigation. //-------------------------------------------------------------------// void DateTimeSelector::OnSelchangeDatetimeCalendar(NMHDR* pNMHDR, LRESULT* pResult) { LPNMSELCHANGE lpNMSelChange = (LPNMSELCHANGE)pNMHDR; // Update the date selector. m_SelectedDate = lpNMSelChange->stSelStart; // Redisplay JUST THE DATE SELECTOR or we have problems. // UpdateData( FALSE ); CDataExchange DX( this, // m_pDlgWnd FALSE // m_bValidateAndSave ); DDX_DateTimeCtrl( &DX, IDC_DATETIME_DATE_SELECTOR, m_SelectedDate); *pResult = 0; }
void Viewpoint::update(){ //todo double dx = objToTrack->VX(); double dy = objToTrack->VY(); double dz = objToTrack->VZ(); double x = objToTrack->X()-10*dx; double y = objToTrack->Y()-20*dy; double z = objToTrack->Z()-10*dz; X(x); Y(y); Z(z); DX(-dx); DY(dy); DZ(dz); }
static inline void calcJD(void) { for(int i=1; i<N_PX-1; i++){ for(int j=1; j<N_PY-1; j++){ double complex nowJx = JX(i,j); Jx[ind(i,j)] = CJX(i,j)*JX(i,j) + CJXHZ(i,j)*(HZ(i,j) - HZ(i,j-1)); Dx[ind(i,j)] = CDX(i,j)*DX(i,j) + CDXJX1(i,j)*JX(i,j) - CDXJX0(i,j)*nowJx; } } for(int i=1; i<N_PX-1; i++){ for(int j=1; j<N_PY-1; j++){ double complex nowJy = JY(i,j); Jy[ind(i,j)] = CJY(i,j)*JY(i,j) + CJYHZ(i,j)*(-HZ(i,j) + HZ(i-1,j)); Dy[ind(i,j)] = CDY(i,j)*DY(i,j) + CDYJY1(i,j)*JY(i,j) - CDYJY0(i,j)*nowJy; } } }