/** * @brief Sestaveni celeho okna kalkulaci a pozicovani objektu */ MainWindow::MainWindow(QWidget *parent) : /* nize je napozicovany kazdy jednotlivy objekt kalkulacky, a take spusteni signalu */ QMainWindow(parent) { this->setWindowTitle("Kalkulačka Vořežpruti"); lcd = new QLCDNumber(10, this); lcd -> setGeometry(QRect(QPoint(50,50), QSize(200, 50))); clear_button = new QPushButton("C",this); clear_button -> setGeometry(QRect(QPoint(200,300), QSize(50,50))); connect(clear_button, SIGNAL(released()), this, SLOT(clear())); napoveda_button = new QPushButton("?", this); napoveda_button -> setGeometry(QRect(QPoint(125,400), QSize(50,50))); connect(napoveda_button, SIGNAL(released()), this, SLOT(napoveda())); rovno_button = new QPushButton("=", this); rovno_button -> setGeometry(QRect(QPoint(50,350), QSize(200,50))); connect(rovno_button, SIGNAL(released()), this, SLOT(rovno())); scitani_button = new QPushButton("+", this); scitani_button -> setGeometry(QRect(QPoint(50,100), QSize(50,50))); connect(scitani_button, SIGNAL(released()), this, SLOT(scitani())); nasobeni_button = new QPushButton("x", this); nasobeni_button -> setGeometry(QRect(QPoint(150,100), QSize(50,50))); connect(nasobeni_button, SIGNAL(released()), this, SLOT(nasobeni())); deleni_button = new QPushButton("/", this); deleni_button -> setGeometry(QRect(QPoint(200,100), QSize(50,50))); connect(deleni_button, SIGNAL(released()), this, SLOT(deleni())); odcitani_button = new QPushButton("-", this); odcitani_button -> setGeometry(QRect(QPoint(100,100), QSize(50,50))); connect(odcitani_button, SIGNAL(released()), this, SLOT(odcitani())); nula_button = new QPushButton("0", this); nula_button -> setGeometry(QRect(QPoint(50,300), QSize(50,50))); connect(nula_button, SIGNAL(released()), this, SLOT(nula())); jedna_button = new QPushButton("1", this); jedna_button -> setGeometry(QRect(QPoint(50,250), QSize(50,50))); connect(jedna_button, SIGNAL(released()), this, SLOT(jedna())); dva_button = new QPushButton("2", this); dva_button -> setGeometry(QRect(QPoint(100,250), QSize(50,50))); connect(dva_button, SIGNAL(released()), this, SLOT(dva())); tri_button = new QPushButton("3", this); tri_button -> setGeometry(QRect(QPoint(150,250), QSize(50,50))); connect(tri_button, SIGNAL(released()), this, SLOT(tri())); ctyri_button = new QPushButton("4", this); ctyri_button -> setGeometry(QRect(QPoint(50,200), QSize(50,50))); connect(ctyri_button, SIGNAL(released()), this, SLOT(ctyri())); pet_button = new QPushButton("5", this); pet_button -> setGeometry(QRect(QPoint(100,200), QSize(50,50))); connect(pet_button, SIGNAL(released()), this, SLOT(pet())); sest_button = new QPushButton("6", this); sest_button -> setGeometry(QRect(QPoint(150,200), QSize(50,50))); connect(sest_button, SIGNAL(released()), this, SLOT(sest())); sedm_button = new QPushButton("7", this); sedm_button -> setGeometry(QRect(QPoint(50,150), QSize(50,50))); connect(sedm_button, SIGNAL(released()), this, SLOT(sedm())); osm_button = new QPushButton("8", this); osm_button -> setGeometry(QRect(QPoint(100,150), QSize(50,50))); connect(osm_button, SIGNAL(released()), this, SLOT(osm())); devet_button = new QPushButton("9", this); devet_button -> setGeometry(QRect(QPoint(150,150), QSize(50,50))); connect(devet_button, SIGNAL(released()), this, SLOT(devet())); tecka_button = new QPushButton(".", this); tecka_button -> setGeometry(QRect(QPoint(100,300), QSize(50,50))); connect(tecka_button, SIGNAL(released()), this, SLOT(tecka())); faktorial_button = new QPushButton("!", this); faktorial_button -> setGeometry(QRect(QPoint(200,150), QSize(50,50))); connect(faktorial_button, SIGNAL(released()), this, SLOT(faktorial())); mocnina_button = new QPushButton("^", this); mocnina_button -> setGeometry(QRect(QPoint(200,200), QSize(50,50))); connect(mocnina_button, SIGNAL(released()), this, SLOT(mocnina())); odmocnina_button = new QPushButton("sqrt", this); odmocnina_button -> setGeometry(QRect(QPoint(200,250), QSize(50,50))); connect(odmocnina_button, SIGNAL(released()), this, SLOT(odmocnina())); negate_button = new QPushButton("+/-", this); negate_button -> setGeometry(QRect(QPoint(150,300), QSize(50,50))); connect(negate_button, SIGNAL(released()), this, SLOT(negate())); }
void Communicator::doDiffusion() { int row = site->row, col = site->col; const VectorAccess<double> &xVector = site->integrator->state(); vector<double> dVector(xVector.size()); // make it the same size if (parameters.totalGridSize() == 1) return; if (parameters.outputMPIMessages()) { char buf[10000]; sprintf(buf,"%g beginning diffusion, variables = (", site->integrator->time()); bool comma = false; for (int vi = 0; vi != site->community->nVars(); vi++ ) if (xVector[vi] > 0) { Indexing::unique_key_type vk = site->community->variableIndexing().key(vi); sprintf(strchr(buf,'\0'), (comma? ", %i" : ((comma=true)," %i")), vk); } strcat(buf," )\n"); site->node->outputcontroller->log("%s",buf); } stl_dvectorAccess dva(dVector); site->community->calcDiffusion(&xVector, &dva); // have to use blip for communicating even locally because everything // has to be indexed by uniqueIDs const char *out_blip = writeDiffusionBlip(&dva); // forget about parity, use buffered send then polling for receive sendDiffusionToNeighbor(out_blip, row, col-1); sendDiffusionToNeighbor(out_blip, row+1, col); sendDiffusionToNeighbor(out_blip, row, col+1); sendDiffusionToNeighbor(out_blip, row-1, col); receiveDiffusionFromNeighbor(row, col-1); receiveDiffusionFromNeighbor(row+1, col); receiveDiffusionFromNeighbor(row, col+1); receiveDiffusionFromNeighbor(row-1, col); if ( parameters.outputMPIMessages() ) { char buf[10000]; // not needed since it's a ref now? //xVector = site->integrator->state(); sprintf(buf, "%g finishing diffusion, variables = (", site->integrator->time()); bool comma = false; for ( long vi = 0; vi != site->community->nVars(); vi++ ) if ( xVector[vi] > 0 ) { Indexing::unique_key_type vk = site->community->variableIndexing().key(vi); sprintf(strchr(buf,'\0'), (comma? ", %i" : ((comma=true)," %i")), vk); } strcat(buf," )\n"); site->node->outputcontroller->log("%s",buf); } }