void CObjectView::resetView(){ tr[0] = 0; tr[1] = 0; tr[2] = 0; scale = 1.0; clearMatrix(m); clearMatrix(mL); RedrawWindow(); }
void LedMatrix::writeMessage(char *message) { int display_len = 16;//width*displays/font_width; int i, pix; int msg_len = strlen(message); for (i=0; i < display_len; i++) { modules[i].init(); } clearMatrix(); for (i=0; i < msg_len; i++ ) { char c = message[i]; drawChar(c, 0, offscreen); for (pix = 0; pix < fontWidth; pix++){ scrollMatrixOnce(pix); } } for (i=0; i < display_len; i++ ) { char c = ' '; drawChar(c, 0, offscreen); for (pix = 0; pix < fontWidth; pix++){ scrollMatrixOnce(pix); } } }
void F4Res::construct(int lev, int degree) { decltype(timer()) timeA, timeB; resetMatrix(lev, degree); timeA = timer(); makeMatrix(); timeB = timer(); mFrame.timeMakeMatrix += seconds(timeB - timeA); if (M2_gbTrace >= 2) mHashTable.dump(); if (M2_gbTrace >= 2) std::cout << " make matrix time: " << seconds(timeB - timeA) << " sec" << std::endl; #if 0 std::cout << "-- rows --" << std::endl; debugOutputReducers(); std::cout << "-- columns --" << std::endl; debugOutputColumns(); std :: cout << "-- reducer matrix --" << std::endl; if (true or lev <= 2) debugOutputMatrix(mReducers); else debugOutputMatrixSparse(mReducers); std :: cout << "-- reducer matrix --" << std::endl; debugOutputMatrix(mReducers); debugOutputMatrixSparse(mReducers); std :: cout << "-- spair matrix --" << std::endl; debugOutputMatrix(mSPairs); debugOutputMatrixSparse(mSPairs); #endif if (M2_gbTrace >= 2) std::cout << " (degree,level)=(" << (mThisDegree - mThisLevel) << "," << mThisLevel << ") #spairs=" << mSPairs.size() << " reducer= " << mReducers.size() << " x " << mReducers.size() << std::endl; if (M2_gbTrace >= 2) std::cout << " gauss reduce matrix" << std::endl; timeA = timer(); gaussReduce(); timeB = timer(); mFrame.timeGaussMatrix += seconds(timeB - timeA); if (M2_gbTrace >= 2) std::cout << " time: " << seconds(timeB - timeA) << " sec" << std::endl; // mFrame.show(-1); timeA = timer(); clearMatrix(); timeB = timer(); mFrame.timeClearMatrix += seconds(timeB - timeA); }
void MainWindow::Buttons() { connect(m_pb_ok, SIGNAL(clicked()), this, SLOT(slot_pb_ok())); connect(m_le_countTops, SIGNAL(textEdited(QString)), this,SLOT(slot_set_table(QString))); connect(m_le_density,SIGNAL(textEdited(QString)), this, SLOT(slot_densityChanged())); connect(this, SIGNAL(setMatrix(int,int,int)),m_math, SLOT(set_matrix(int,int,int))); connect(this, SIGNAL(calcFloid()), m_math, SLOT(floyd())); connect(this, SIGNAL(getResults(int,int)), m_math, SLOT(get_results(int,int))); connect(this, SIGNAL(clearMatrix()), m_math, SLOT(clear_Matrix())); }
// Anzeigefunktion void showAll() { clearMatrix(); byte matrixSize = getMatrixSize(); for (int i = 0; i < matrixSize; i++) { setMatrix(i, 65535); } writeMatrix(); return; }
void MatrixGenerator::clearMatrixAndResultVector() { clearMatrix(); clearResultVector(); notNullElementsCount = 0; // for (int i=0 ; i<m ; i++) // delete [] matrix[i]; // delete matrix; // delete resultVector; //initializeMatrixAndVector(); }
void motion(int velocidade) { int x, y = 0, aux = 1, count = 0; char matrix[LINHAS][COLUNAS]; //Config ncurses initscr(); noecho(); curs_set(FALSE); x = (LINHAS - 1)/2; while(aux <= 20){ //Subida da bola reduzida em fracoes while(y >= LINHAS - (LINHAS / aux)){ if(count % velocidade == 0){ y--; clearMatrix(matrix); matrix[x][y] = '@'; printMatrix(matrix); } count++; usleep(10000); } //Descida da bola ate tocar a borda inferior while(y < LINHAS - 2){ if(count % velocidade == 0) { y++; clearMatrix(matrix); matrix[x][y] = '@'; printMatrix(matrix); } count++; usleep(5000); } aux++; } usleep(500000); endwin(); }
void MatrixGenerator::initializeMatrixAndVector() { cout << "Initializing matrix and vector... " << flush; matrix = new double*[m]; for (int i=0 ; i<m ; i++) matrix[i] = new double[n]; clearMatrix(); multiVector = new double[n]; for (int i=0 ; i<n ; i++) multiVector[i] = randomValue(1, 2); resultVector = new double[n]; clearResultVector(); cout << "done" << endl; }
void ps2_main(void){ m_state = STA_WAIT_RESET; kbd_init(); keymap_init(); clear(); //set key repeat speed; uint8_t gSpeed = eeprom_read_byte((uint8_t *)EEPROM_PS2_REPEAT_SPEED); if(gSpeed == 0xFF) gSpeed = 1; if(ps2_repeat_speed == PS2_REPEAT_SPEED_NONE){ ps2_repeat_speed = gSpeed; }else if(ps2_repeat_speed != gSpeed){ eeprom_write_byte((uint8_t *)EEPROM_PS2_REPEAT_SPEED, ps2_repeat_speed); } // init setKeyScanDriver(&driverKeyScanPs2); setUpdateDriver(&updatePs2); clearMatrix(); // DEBUG_PRINT(("STARTING PS/2 KEYBOARD\n")); sei(); // DBG1(0x90, 0, 0); for(;;){ // 카운트 이내에 신호가 잡히지 않으면 이동; // 특별한 경우에만 발생하는 현상이다. if(INTERFACE == INTERFACE_PS2 && interfaceReady == false && interfaceCount++ > 1000){ // move to usb INTERFACE = INTERFACE_USB; DBG1(0x99, 0, 0); break; } processRxPs2(); processTxPs2(); } // DBG1(0x9F, 0, 0); }
void MainWindow::slot_pb_ok() { emit clearMatrix(); slot_set_table(m_le_countTops->text()); clear(); int countTops = m_le_countTops->text().toInt(); for(int i = STEP_SIZE; i <= countTops; i+=STEP_SIZE) { slot_set_table(QString::number(i)); for(int k = 0; k < SAMPLE_SIZE; k++) { slot_LoadData(i); calcFloid(); m_math->dijkstra(); m_math->randomSearch(); } steps << (double)i; } outGraph(); //m_lb_resultOut->setText(QString::number(result, 'i', 0)); }
// Anzeige je Frame void showPong() { int i; clearMatrix(); // Linie für das obere Paddle anzeigen writeLine(pong.paddleUp.posX, pong.paddleUp.posY, pong.paddleUp.posX + PADDLEWIDTH - 1, pong.paddleUp.posY); // Linie für das untere Paddle anzeigen writeLine(pong.paddleDown.posX, pong.paddleDown.posY, pong.paddleDown.posX + PADDLEWIDTH - 1, pong.paddleDown.posY); // Ball anzeigen setLED(pong.ball.posX, pong.ball.posY); // Die Matrix auf die LEDs multiplexen writeMatrix(); return; }
int main() { double *A, **t, x0; int i, n; char chce_podac_x[2]; do { printf("Podaj liczbę naturalną z przedziału od 0 do %d: ", N_MAX); scanf("%d", &n); } while(n < 0 || n > N_MAX); n += 1; A = malloc(n * sizeof (double)); for (i = 0; i < n; i++) { printf("Podaj A[%d]: ", i); scanf("%lf", &A[i]); } t = malloc(n * sizeof (double*)); for (i = 0; i < n; i++) { t[i] = malloc((n + 1) * sizeof (double)); } do { printf("Podaj X0: "); scanf("%lf", &x0); clearMatrix(n, t, A); fillMatrix(n, t, x0); resolveMatrix(n, t); printPolynomial(n, t); do { printf("Chcesz podać kolejne X0? (tak/nie): "); scanf("%s", chce_podac_x); if(strcmp(chce_podac_x, "tak") == 0 || strcmp(chce_podac_x, "nie") == 0) break; } while(1); } while (strcmp(chce_podac_x, "tak") == 0); return 0; }
void BlockConstraint<Type>::operator= ( const BlockConstraint<Type>& rhs ) { // Check for assignment to self if (this == &rhs) { FatalErrorIn ( "BlockConstraint::operator=(const BlockConstraint&)" ) << "attempted assignment to self" << abort(FatalError); } rowID_ = rhs.rowID_; value_ = rhs.value_; fixedComponents_ = rhs.fixedComponents_; clearMatrix(); }
void PckReceiver::setup(){ //serial.listDevices(); vector <ofSerialDeviceInfo> deviceList = serial.getDeviceList(); if(deviceList.size() == 0){ ofLog(OF_LOG_FATAL_ERROR) << "PckReceiver: no serial / CDC devices found. application abort...\n"; OF_EXIT_APP(1); } ofLog() << "PckReceiver: list of all available devices"; vector <ofSerialDeviceInfo>::iterator it = deviceList.begin(); while(it != deviceList.end()){ ofSerialDeviceInfo info = *it; ofLog() << info.getDevicePath() << " " << info.getDeviceName() << " " <<info.getDeviceID(); it++; } int baud = 9600; if(!serial.setup("/dev/ttyACM0",baud)){ ofLog(OF_LOG_FATAL_ERROR) << "PckReceiver: could not initialize serial"; OF_EXIT_APP(1); } ofLog() << "PckReceiver: established connection to Peacock Hardware"; clearMatrix(preMatrix); }
/** * Main function, containing the main loop that manages timer- and * USB-functionality. * /return the obligatory integer that nobody cares about... */ void usb_main(void) { // USB Reset by device only required on Watchdog Reset P2U_PS2_PORT &= ~((1 << P2U_PS2_CLOCK_PIN)|(1 << P2U_PS2_DATA_PIN)); // input:tri-state output:low P2U_USB_CFG_DDR &= ~((1 << P2U_USB_CFG_DPLUS_BIT)|(1 << P2U_USB_CFG_DMINUS_BIT));// input, remove USB reset condition // configure timer 0 for a rate of 12M/(1024 * 256) = 45.78Hz (~22ms) //TCCR0 |= (1<<CS02)|(1<<CS00); // timer 0 prescaler: 1024 // TCCR0 &= ~((1<<CS02)|(1<<CS01)|(1<<CS00)); // timer stop usbInit(); uint8_t idleCounter = 0; uchar i = 0; usbDeviceDisconnect(); /* do this while interrupts are disabled */ do{ /* fake USB disconnect for > 250 ms */ // wdt_reset(); _delay_ms(1); }while(--i); usbDeviceConnect(); // init setKeyScanDriver(&driverKeyScanUsb); setUpdateDriver(&updateUsb); clearReportBuffer(); sei(); #if USB_COUNT_SOF bool _isSuspended = false; int suspendCount = 0; #endif for(;;){ #ifndef INTERFACE_ONLY_USB // 카운트 이내에 신호가 잡히지 않으면 이동; // 특별한 경우에만 발생하는 현상이다. if(INTERFACE == INTERFACE_USB && interfaceReady == false && interfaceCount++ > 3000){ // move to ps/2 INTERFACE = INTERFACE_PS2; DBG1(0x88, 0, 0); break; } #endif #if USB_COUNT_SOF if (usbSofCount != 0) { // DBG1(0x55, (uchar *)&usbSofCount, 1); _isSuspended = false; usbSofCount = 0; suspendCount = 0; _usbReset = false; wakeUp(); } else if(_usbReset == true){ // DBG1(0x56, (uchar *)&usbSofCount, 1); _isSuspended = false; usbSofCount = 1; wakeUp(); }else{ // Suspend when no SOF in 3ms-10ms(7.1.7.4 Suspending of USB1.1) if (_isSuspended == false && suspendCount++ > 10000 && getModifierDownBuffer() == 0 && getDownBufferAt(0) == 0) { // DBG1(0x5a, (uchar *)&usbSofCount, 2); _isSuspended = true; sleep(); } } #endif // main event loop usbPoll(); #if USB_COUNT_SOF /*if(_isSuspended == true) { continue; }*/ #endif // check timer if we need periodic reports if (TIFR & (1 << TOV0)) { TIFR = (1 << TOV0); // reset flag if (idleRate != 0) { // do we need periodic reports? if(idleCounter > 4){ // yes, but not yet idleCounter -= 5; // 22ms in units of 4ms } else { // yes, it is time now updateNeeded = 1; idleCounter = idleRate; } } } // if an update is needed, send the report if (usbInterruptIsReady()) { scanKeyUsbWithMacro(); // changes? // ps2avrU loop, must be after scan matrix; enterFrame(); if(updateNeeded){ if(interfaceReady==false) continue; memset(reportKeyboard, 0, REPORT_SIZE_KEYBOARD); reportKeyboard[0] = _modifiers; reportKeyboard[1] = 0; memcpy ( reportKeyboard+2, reportBuffer, strlen((char *)reportBuffer) ); // DBG1(0x06, (uchar *)&reportKeyboard[0], 1); usbSetInterrupt((void *)&reportKeyboard, sizeof(reportKeyboard)); updateNeeded = 0; #if !USB_COUNT_SOF wakeUpUsb(); #endif }else if(_initState == INIT_INDEX_SET_IDLE){ DBG1(0x99, (uchar *)&_initState, 1); _initState = INIT_INDEX_INITED; // 재부팅시 첫키 입력 오류를 방지하기 위해서 HID init 후 all release 전송; memset(reportKeyboard, 0, REPORT_SIZE_KEYBOARD); usbSetInterrupt((void *)&reportKeyboard, sizeof(reportKeyboard)); clearMatrix(); #if !USB_COUNT_SOF wakeUpUsb(); #endif // 플러깅 후 출력되는 메세지는 넘락등 LED가 반응한 후에 보여진다. // usbInterruptIsReady() 일지라도 LED 반응 전에는 출력이 되지 않는다. // LED 반응 후에 처리하려고 하면 MAC OS에서 실행되지 않는다. // (MAC OS에서는 플러깅 시 LED가 반응하지 않는다. 대신 바로 출력이 된다.) // for os x if(idleRate > 0) { startKeyMappingOnBoot(); } // DBG1(0xAA, (uchar *)&idleRate, 1); }else if(_ledInitState == INIT_INDEX_INITED){ _ledInitState = INIT_INDEX_COMPLETE; // for windows if(idleRate == 0) { startKeyMappingOnBoot(); } } } if(usbInterruptIsReady3()){ if(_extraHasChanged){ report_extra_t gReportExtra = { .report_id = REPORT_ID_CONSUMER, .usage = extraData }; usbSetInterrupt3((void *)&gReportExtra, sizeof(gReportExtra)); _extraHasChanged = false; #if !USB_COUNT_SOF wakeUpUsb(); #endif } if(_systemHasChanged){ report_extra_t gReportExtra = { .report_id = REPORT_ID_SYSTEM, .usage = systemData }; usbSetInterrupt3((void *)&gReportExtra, sizeof(gReportExtra)); _systemHasChanged = false; #if !USB_COUNT_SOF wakeUpUsb(); #endif } } if(_initState == INIT_INDEX_INITED){ if(initCount++ == 200){ // delay for OS X USB multi device // all platform init led initAfterInterfaceMount(); }else if(initCount > 200){ initCount = 201; _initState = INIT_INDEX_COMPLETE; } } #if !USB_COUNT_SOF // 입력이 한동안 없으면 슬립모드로; countSleepUsb(); #endif } #ifndef INTERFACE_ONLY_USB // data line reset; USB_INTR_ENABLE &= ~(1 << USB_INTR_ENABLE_BIT); #endif }
/** * Main function, containing the main loop that manages timer- and * USB-functionality. * /return the obligatory integer that nobody cares about... */ void usb_main(void) { // USB Reset by device only required on Watchdog Reset P2U_PS2_PORT &= ~((1 << P2U_PS2_CLOCK_PIN)|(1 << P2U_PS2_DATA_PIN)); // input:tri-state output:low P2U_USB_CFG_DDR &= ~((1 << P2U_USB_CFG_DPLUS_BIT)|(1 << P2U_USB_CFG_DMINUS_BIT));// input, remove USB reset condition usbInit(); int interfaceCount = 0; if( eeprom_read_byte((uint8_t *)EEPROM_USB_COMPATIBILITY) == 0x00 ) { usbDeviceDisconnect(); /* do this while interrupts are disabled */ uchar i = 0; do{ /* fake USB disconnect for > 250 ms */ wdt_reset(); _delay_ms(1); }while(--i); } usbDeviceConnect(); // init setKeyScanDriver(&driverKeyScanUsb); setUpdateDriver(&updateUsb); clearReportBuffer(); sei(); #if USB_COUNT_SOF bool _isSuspended = false; int suspendCount = 0; #endif for(;;){ /* * USB3.0 + win10의 경우 usbDeviceConnect() 딜레이가 있으면 일부 장치에서 인식이 되지않아 이를 제거 * 하지만, 구식 부트로더 (ps2avrGB_bootloader_140623)의 경우 빠져나올 때 usbDeviceDisconnect()를 처리하지 않아서 * 이를 여기서 처리해줌. */ if(interfaceReady == false && interfaceCount++ > 1000) { cli(); usbDeviceDisconnect(); wdt_enable(WDTO_15MS); for(;;); } #if USB_COUNT_SOF if (usbSofCount != 0) { _isSuspended = false; usbSofCount = 0; suspendCount = 0; _usbReset = false; wakeUp(); } else if(_usbReset == true){ _isSuspended = false; usbSofCount = 1; wakeUp(); }else{ // Suspend when no SOF in 3ms-10ms(7.1.7.4 Suspending of USB1.1) if (_isSuspended == false && suspendCount++ > 1000 && isReleaseAll()) { _isSuspended = true; sleep(); } } #endif // main event loop usbPoll(); // if an update is needed, send the report if (usbInterruptIsReady()) { scanKeyUsbWithMacro(); // changes? if(updateNeeded){ if(interfaceReady==false) continue; #if USB_COUNT_SOF if(_isSuspended == true) { wake_up_signal(); updateNeeded = 0; continue; } #endif memset(reportKeyboard, 0, REPORT_SIZE_KEYBOARD); reportKeyboard[0] = _modifiers; reportKeyboard[1] = 0; memcpy ( reportKeyboard+2, reportBuffer, _countOfBuffer ); //strlen((char *)reportBuffer) ); // DBG1(0x06, (uchar *)&reportKeyboard, 8); usbSetInterrupt((void *)&reportKeyboard, sizeof(reportKeyboard)); updateNeeded = 0; #if !USB_COUNT_SOF wakeUpUsb(); #endif }else if(_initState == INIT_INDEX_SET_IDLE){ // DBG1(0x99, (uchar *)&_initState, 1); _initState = INIT_INDEX_INITED; // 재부팅시 첫키 입력 오류를 방지하기 위해서 HID init 후 all release 전송; memset(reportKeyboard, 0, REPORT_SIZE_KEYBOARD); usbSetInterrupt((void *)&reportKeyboard, sizeof(reportKeyboard)); clearMatrix(); #if !USB_COUNT_SOF wakeUpUsb(); #endif // 플러깅 후 출력되는 메세지는 넘락등 LED가 반응한 후에 보여진다. // usbInterruptIsReady() 일지라도 LED 반응 전에는 출력이 되지 않는다. // LED 반응 후에 처리하려고 하면 MAC OS에서 실행되지 않는다. // (MAC OS에서는 플러깅 시 LED가 반응하지 않는다. 대신 바로 출력이 된다.) // for os x // DBG1(0xAA, (uchar *)&idleRate, 1); }else if(_ledInitState == INIT_LED_INDEX_INITED){ _ledInitState = INIT_LED_INDEX_COMPLETE; // for windows } // ps2avrU loop, must be after scan matrix; enterFrame(); } #if !defined( USING_SIMPLE_MODE ) if(usbInterruptIsReady3()){ if(_extraHasChanged){ report_extra_t gReportExtra = { .report_id = REPORT_ID_CONSUMER, .usage = extraData }; usbSetInterrupt3((void *)&gReportExtra, sizeof(gReportExtra)); _extraHasChanged = false; #if !USB_COUNT_SOF wakeUpUsb(); #endif } if(_systemHasChanged){ report_extra_t gReportExtra = { .report_id = REPORT_ID_SYSTEM, .usage = systemData }; usbSetInterrupt3((void *)&gReportExtra, sizeof(gReportExtra)); _systemHasChanged = false; #if !USB_COUNT_SOF wakeUpUsb(); #endif } } #endif if(_initState == INIT_INDEX_INITED){ if(initCount++ == 200){ // delay for OS X USB multi device // all platform init led initAfterInterfaceMount(); // DBG1(0xAB, (uchar *)&initCount, 2); }else if(initCount > 200){ initCount = 201; _initState = INIT_INDEX_COMPLETE; } } #if !USB_COUNT_SOF // 입력이 한동안 없으면 슬립모드로; countSleepUsb(); #endif } /* #if !defined(INTERFACE_ONLY_USB) // data line reset; USB_INTR_ENABLE &= ~(1 << USB_INTR_ENABLE_BIT); #endif */ }
int main(int argc,char* argv[]) { if(argc!=4) { printf("Wrong Arguments!"); return 1; } FILE * fhand=fopen ( argv[1], "r" ); if(fhand==0) { printf("File Open Error."); return 1; } int i,len; fscanf(fhand,"%d",&len); Matrix edgeMat; int edgeCount= readMatrix(&edgeMat,fhand,len); fclose(fhand); if(strcmp(argv[2],"-p")==0) { int *parent= (int*) malloc(len*sizeof(int)); //holds MST tree as parent array int *intree= (int*) malloc(len*sizeof(int));//holds edges in MST int *near= (int*) malloc(len*sizeof(int)); //holds distance to MST if(parent==0||intree==0||near==0) { printf("Memory Allocation Error!"); exit(1); } fhand=fopen ( argv[3], "w" ); if(fhand==0){ printf("File Write Protected or In Use!"); return 1; } prim(parent,near,intree,&edgeMat); int sum=0; Matrix result; createMatrix(&result,len); for(i=1;i<len;i++) { if(parent[i]!=-1) { result.data[i][parent[i]]=1;result.data[parent[i]][i]=1; sum+=edgeMat.data[i][parent[i]]; } } fprintf(fhand,"%d\n%d\n",len,sum); writeMatrix(&result,fhand); clearMatrix(&result); fclose(fhand); } else if(strcmp(argv[2],"-k")==0) { //Edge_heap eheap; init_heap(&eheap,len*len/2); edge *ex= (edge*) malloc(edgeCount*sizeof(edge)); if(ex==0){ printf("Memory Allocation Error!"); exit(1);} int n,m,k=0; for(n=0;n<len-1;n++) { //just travels upper triangular of matrix for (m=n+1;m<len;m++) { if(edgeMat.data[n][m]!=0) { init_edge(&ex[k],n,m,&edgeMat); //insert(&edgeMat,&eheap,&ex[k]); if(++k==edgeCount) break; } } if(k==edgeCount) break; } clearMatrix(&edgeMat); Matrix result; createMatrix(&result,len); DisjSets dset; init_DisjSets(&dset,len); fhand=fopen ( argv[3], "w" ); if(fhand==0){ printf("File Write Protected or In Use!"); return 1; } fprintf(fhand,"%d\n%d\n",len,kruskal(&result,&dset,ex,edgeCount)); writeMatrix(&result,fhand); clearMatrix(&result); fclose(fhand); } else { printf("Wrong Arguments!"); return 1; } return 0; }