double InterMolecularTorsions::compute( const unsigned& tindex, multicolvar::AtomValuePack& myatoms ) const { Vector v1, v2, dv1, dv2, dconn, conn = getSeparation( myatoms.getPosition(0), myatoms.getPosition(1) ); // Retrieve vectors std::vector<double> orient0( 5 ), orient1( 5 ); getInputData( 0, true, myatoms, orient0 ); getInputData( 1, true, myatoms, orient1 ); for(unsigned i=0; i<3; ++i) { v1[i]=orient0[2+i]; v2[i]=orient1[2+i]; } if( getBaseMultiColvar(0)->getNumberOfQuantities()<3 ) return 1.0; // Evaluate angle Torsion t; double angle = t.compute( v1, conn, v2, dv1, dconn, dv2 ); for(unsigned i=0; i<3; ++i) { orient0[i+2]=dv1[i]; orient1[i+2]=dv2[i]; } // And accumulate derivatives if( !doNotCalculateDerivatives() ) { MultiValue& myder0=getInputDerivatives( 0, true, myatoms ); mergeInputDerivatives( 1, 2, orient1.size(), 0, orient0, myder0, myatoms ); MultiValue& myder1=getInputDerivatives( 1, true, myatoms ); mergeInputDerivatives( 1, 2, orient0.size(), 1, orient1, myder1, myatoms ); addAtomDerivatives( 1, 0, -dconn, myatoms ); addAtomDerivatives( 1, 1, dconn, myatoms ); myatoms.addBoxDerivatives( 1, -extProduct( conn, dconn ) ); } return angle; }
sBool doProcess() { sInt *kern, len; frTexture *src2, *dst1; sBool blurred; frTexture *temp=new frTexture(data->w, data->h); temp->lock(); if (params[0].tfloatv.a<=1.0f && params[1].floatv==1.0f) src2=getInputData(0); else src2=temp; if (params[0].tfloatv.b<=1.0f && params[1].floatv==1.0f) dst1=data; else dst1=temp; blurred=sFALSE; if (params[1].floatv>0.0f) { if (params[0].tfloatv.a>1.0f || params[1].floatv!=1.0f) { kern=filters[params[2].selectv.sel](params[0].tfloatv.a, len, params[1].floatv); blur(dst1, getInputData(0), len, params[3].selectv.sel, 0); blurred=sTRUE; } if (params[0].tfloatv.b>1.0f || params[1].floatv!=1.0f) { kern=filters[params[2].selectv.sel](params[0].tfloatv.b, len, params[1].floatv); blur(data, src2, len, params[3].selectv.sel, 1); blurred=sTRUE; } if (!blurred) data->copy(*getInputData(0)); } else memset(data->data, 0, data->w*data->h*4*sizeof(sU16)); temp->unlock(); delete temp; return sTRUE; }
int itkFiltersComponentSizeThresholdProcess::tryUpdate() { int res = DTK_FAILURE; if ( getInputData() ) { res = DISPATCH_ON_3D_PIXEL_TYPE(&itkFiltersComponentSizeThresholdProcess::updateProcess, this, getInputData()); } return res; }
int itkFiltersMedianProcess::tryUpdate() { int res = DTK_FAILURE; if ( getInputData() ) { res = DISPATCH_ON_3D_PIXEL_TYPE(&itkFiltersMedianProcess::updateProcess, this, getInputData()); } return res; }
int main() { int rowNum=0, colNum=0; int rowIndex=0, colIndex=0, k = 0, l = 0; int minRow=0, maxColumn=0, isFound = 0; int tmpBuf = 0; int i=0,j=0; double data[MaxCol][MaxCol]; getInputData(&rowNum, &colNum, data); int spaceNum = 0; int spaceFlag = 0; for(rowIndex=0; rowIndex < rowNum; rowIndex++) { for( colIndex = 0; colIndex < colNum; colIndex++) { minRow = data[rowIndex][colIndex]; for( k = 0 ; k < colNum; k++) { if( minRow > data[rowIndex][k]) break; } //make sure a[i][j] is the smallest in row[i] if( k==colNum ) { maxColumn = data[rowIndex][colIndex]; for(l=0; l < rowNum; l++) { if(maxColumn < data[l][colIndex]) break; } // make sure a[i][j] is the biggest in column[j] if( l == rowNum ) { printf("(%d,%d)\n",rowIndex , colIndex); isFound = 1; } } } } if(isFound==0) printf("Not Found\n"); return 0; }
//------------------------------------------------------------------------------ // Handle input devices //------------------------------------------------------------------------------ void IoHandler::inputDevices(const LCreal dt) { BaseClass::inputDevices(dt); // --- // get the Input data buffer // --- const Basic::IoData* const inData = getInputData(); // --- // get the Station, Simulation and our ownship player // --- SimStation* const sta = static_cast<SimStation*>( findContainerByType(typeid(SimStation)) ); Simulation::Simulation* sim = 0; Simulation::AirVehicle* av = 0; if (sta != 0) { sim = sta->getSimulation(); av = dynamic_cast<Simulation::AirVehicle*>(sta->getOwnship()); } // --- // If we have everything we need .... // --- if (av != 0 && sim != 0 && inData != 0) { // find the (optional) autopilot Simulation::Autopilot* ap = 0; { Basic::Pair* p = av->getPilotByType( typeid( Simulation::Autopilot) ); if (p != 0) ap = static_cast<Simulation::Autopilot*>( p->object() ); } // ------------------------------------------------------------ // Simulation Control Inputs // ------------------------------------------------------------ { bool enabled = false; inData->getDiscreteInput(CTL_ENABLE_SW, &enabled); { // Toggle simulation freeze bool sw = false; inData->getDiscreteInput(FREEZE_SW, &sw); bool frzSw = sw && enabled; if (frzSw && !frzSw1) { Basic::Boolean newFrz( !sim->isFrozen() ); sim->event(FREEZE_EVENT, &newFrz); } frzSw1 = frzSw; } { // Send a reset pulse to the station bool sw = false; inData->getDiscreteInput(RESET_SW, &sw); bool rstSw = sw && enabled; if (rstSw && !rstSw1) { sta->event(RESET_EVENT); } rstSw1 = rstSw; } { // Send a weapons reload pulse to the station bool sw = false; inData->getDiscreteInput(RELOAD_SW, &sw); bool wpnReloadSw = sw && enabled; if (wpnReloadSw && !wpnReloadSw1) { sta->event(WPN_RELOAD); } wpnReloadSw1 = wpnReloadSw; } } // ------------------------------------------------------------ // Flight Control Inputs // ------------------------------------------------------------ { // Process Roll Input LCreal ai = 0; inData->getAnalogInput(ROLL_AI, &ai); LCreal aiLim = alim(ai, 1.0f); if (ap != 0) ap->setControlStickRollInput(aiLim); else av->setControlStickRollInput(aiLim); } { // Process Pitch Input LCreal ai = 0; inData->getAnalogInput(PITCH_AI, &ai); LCreal aiLim = alim(ai, 1.0f); if (ap != 0) ap->setControlStickPitchInput(aiLim); else av->setControlStickPitchInput(aiLim); } { // Process Rudder Input LCreal ai = 0; inData->getAnalogInput(RUDDER_AI, &ai); LCreal aiLim = alim(ai, 1.0f); av->setRudderPedalInput(aiLim); } { // Process Throttle Input LCreal value = 0; inData->getAnalogInput(THROTTLE_AI, &value); if (value < 0.0f) value = 0.0f; else if (value > 2.0f) value = 2.0f; if (ap != 0) ap->setThrottles(&value,1); else av->setThrottles(&value,1); } { // Weapons Release bool sw = false; inData->getDiscreteInput(PICKLE_SW, &sw); if (sw != wpnRelSw1) { Basic::Boolean sw(sw); av->event(WPN_REL_EVENT, &sw); } wpnRelSw1 = sw; } { // Trigger switch bool sw = false; inData->getDiscreteInput(TRIGGER_SW2, &sw); if (sw != trgSw1) { Basic::Boolean sw(sw); av->event(TRIGGER_SW_EVENT, &sw); } trgSw1 = sw; } { // Target Step (reject) bool sw = false; inData->getDiscreteInput(TMS_RIGHT_SW, &sw); if (sw && !tgtStepSw1) { av->event(TGT_STEP_EVENT); } tgtStepSw1 = sw; } { // Target Designate bool sw = false; inData->getDiscreteInput(TMS_UP_SW, &sw); if (sw && !tgtDesSw1) { av->event(TGT_DESIGNATE); } tgtDesSw1 = sw; } { // Return-To-Search bool sw = false; inData->getDiscreteInput(TMS_DOWN_SW, &sw); if (sw && !rtn2SrchSw1) { av->event(SENSOR_RTS); } rtn2SrchSw1 = sw; } { // Autopilot disengage bool autopilotSw = false; inData->getDiscreteInput(PADDLE_SW, &autopilotSw); if (autopilotSw && !autopilotSw1) { Simulation::Autopilot* ap = dynamic_cast<Simulation::Autopilot*>(av->getPilot()); if (ap != 0) { ap->setHeadingHoldMode(false); ap->setAltitudeHoldMode(false); ap->setVelocityHoldMode(false); ap->setLoiterMode(false); ap->setNavMode(false); } } autopilotSw1 = autopilotSw; } { // Speedbrake switch bool sbExtSw = false; bool sbRetSw = false; inData->getDiscreteInput(SB_EXT_SW, &sbExtSw); inData->getDiscreteInput(SB_RET_SW, &sbRetSw); LCreal sb = 0.0; if(sbExtSw) sb = -1.0f; if(sbRetSw) sb = 1.0f; av->setSpeedBrakesSwitch(sb); } { // Steerpoint increment bool incStptSw = false; inData->getDiscreteInput(DMS_UP_SW, &incStptSw); if(incStptSw && !incStptSw1) { // find our route and increment the steerpoint Simulation::Navigation* myNav = av->getNavigation(); if (myNav != 0) { myNav->ref(); Simulation::Route* myRoute = myNav->getPriRoute(); if (myRoute != 0) { myRoute->ref(); myRoute->incStpt(); myRoute->unref(); } } } incStptSw1 = incStptSw; } { // Steerpoint decrement bool decStptSw = false; inData->getDiscreteInput(DMS_DOWN_SW, &decStptSw); if (decStptSw && !decStptSw1) { // find our route and increment the steerpoint Simulation::Navigation* myNav = av->getNavigation(); if (myNav != 0) { myNav->ref(); Simulation::Route* myRoute = myNav->getPriRoute(); if (myRoute != 0) { myRoute->ref(); myRoute->decStpt(); myRoute->unref(); } } } decStptSw1 = decStptSw; } } }
int main ( int argc, char **argv ) /*----------------------------------------------------------------------- */ /* Obit task to automatically edit a uv data set */ /*----------------------------------------------------------------------- */ { oint ierr = 0; ObitSystem *mySystem= NULL; ObitUV *inData = NULL,*outData = NULL; ObitUV *scrData=NULL, *avgData=NULL; ofloat timeAvg; olong avgFreq, nchAvg, BChan, BIF; gboolean isScratch, doAvgAll, allChan; ObitInfoType type; gint32 dim[MAXINFOELEMDIM] = {1,1,1,1,1}; ObitErr *err= NULL; gchar *editParms[] = { /* Parameters to edit data */ "flagTab", "flagSig", "alpha", "timeWind", NULL}; /* Startup - parse command line */ err = newObitErr(); myInput = MednFlagIn (argc, argv, err); if (err->error) {ierr = 1; ObitErrLog(err); goto exit;} /* Initialize logging */ ObitErrInit (err, (gpointer)myInput); ObitErrLog(err); /* show any error messages on err */ if (ierr!=0) return 1; /* Initialize Obit */ mySystem = ObitSystemStartup (pgmName, pgmNumber, AIPSuser, nAIPS, AIPSdirs, nFITS, FITSdirs, (oint)TRUE, (oint)FALSE, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Digest input */ digestInputs(myInput, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Get input uvdata */ inData = getInputData (myInput, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Get output uvdata */ outData = setOutputUV (myInput, inData, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Make scratch file, possibly with time and freq averaging */ avgFreq = 0; ObitInfoListGetTest(myInput, "avgFreq", &type, dim, &avgFreq); BChan = 1; ObitInfoListGetTest(myInput, "BChan", &type, dim, &BChan); BIF = 1; ObitInfoListGetTest(myInput, "BIF", &type, dim, &BIF); nchAvg = 1; ObitInfoListGetTest(myInput, "chAvg", &type, dim, &nchAvg); timeAvg = 0.0; ObitInfoListGetTest(myInput, "avgTime", &type, dim, &timeAvg); /* Average all channels/IFs? */ doAvgAll = (avgFreq==3); allChan = doAvgAll || (avgFreq==2); /* If both tempporal and frequency averaging, frequency average to scratch */ if ((avgFreq>0) && (timeAvg>0.0)) { /* First frequency */ dim[0] = dim[1] = 1; ObitInfoListAlwaysPut (inData->info, "NumChAvg", OBIT_long, dim, &nchAvg); dim[0] = dim[1] = 1; ObitInfoListAlwaysPut (inData->info, "doAvgAll", OBIT_bool, dim, &doAvgAll); isScratch = TRUE; scrData = ObitUVUtilAvgF (inData, isScratch, NULL, err); /* Then time */ dim[0] = 1; ObitInfoListAlwaysPut (scrData->info, "timeAvg", OBIT_float, dim, &timeAvg); isScratch = TRUE; avgData = ObitUVUtilAvgT (scrData, isScratch, NULL, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; scrData = ObitUVUnref(scrData); } else if (avgFreq>0) { /* Freq averaging only */ dim[0] = dim[1] = 1; ObitInfoListAlwaysPut (inData->info, "NumChAvg", OBIT_long, dim, &nchAvg); dim[0] = dim[1] = 1; ObitInfoListAlwaysPut (inData->info, "doAvgAll", OBIT_bool, dim, &doAvgAll); isScratch = TRUE; avgData = ObitUVUtilAvgF (inData, isScratch, NULL, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; } else if (timeAvg>0.0) { /* Time averaging only */ dim[0] = 1; ObitInfoListAlwaysPut (inData->info, "timeAvg", OBIT_float, dim, &timeAvg); isScratch = TRUE; avgData = ObitUVUtilAvgT (inData, isScratch, NULL, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; } else { /* No averaging - straight copy */ /* Scratch file for copy */ avgData = newObitUVScratch (inData, err); /* Calibrate/edit/copy data to scratch file */ avgData = ObitUVCopy (inData, avgData, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; } /* Editing parameters to avgData */ ObitInfoListCopyList (myInput, avgData->info, editParms); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Then time */ dim[0] = 1; ObitInfoListAlwaysPut (avgData->info, "timeAvg", OBIT_float, dim, &timeAvg); /* What's already been done to it */ dim[0] = dim[1] = 1; ObitInfoListAlwaysPut (avgData->info, "begChan", OBIT_long, dim, &BChan); ObitInfoListAlwaysPut (avgData->info, "begIF", OBIT_long, dim, &BIF); ObitInfoListAlwaysPut (avgData->info, "allChan", OBIT_bool, dim, &allChan); /* Do editing */ ObitUVEditMedian (avgData, outData, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Write history */ MednFlagHistory (myInput, outData, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* show any messages and errors */ if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* cleanup */ myInput = ObitInfoListUnref(myInput); /* delete input list */ avgData = ObitUnref(avgData); inData = ObitUnref(inData); outData = ObitUnref(outData); /* Shutdown Obit */ exit: ObitReturnDumpRetCode (ierr, outfile, myOutput, err); myOutput = ObitInfoListUnref(myOutput); /* delete output list */ mySystem = ObitSystemShutdown (mySystem); return ierr; } /* end of main */
int main(void) { //whileLoop(1); getInputData(); return EXIT_SUCCESS; }
void DeviceFilter::handleInput(const std::string& device, const DataGroup& inputData) { filterInput(device, inputData, &getInputData()); pushInput(); }
void DeviceFilter::initializeInput(const std::string& device, const DataGroup& inputData) { filterInput(device, inputData, &getInputData()); }
int main ( int argc, char **argv ) /*----------------------------------------------------------------------- */ /* Obit task to make ionospheric movie from an SN table */ /*----------------------------------------------------------------------- */ { oint ierr = 0; olong ntime = 0; ObitSystem *mySystem= NULL; ObitUV *inData = NULL; ObitImage *outImage = NULL; ObitErr *err= NULL; /* Startup - parse command line */ err = newObitErr(); myInput = IonMovieIn (argc, argv, err); if (err->error) {ierr = 1; ObitErrLog(err); goto exit;} /* Initialize logging */ ObitErrInit (err, (gpointer)myInput); ObitErrLog(err); /* show any error messages on err */ if (ierr!=0) return 1; /* Initialize Obit */ mySystem = ObitSystemStartup (pgmName, pgmNumber, AIPSuser, nAIPS, AIPSdirs, nFITS, FITSdirs, (oint)TRUE, (oint)FALSE, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Digest input */ digestInputs(myInput, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Get input uvdata */ inData = getInputData (myInput, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Count times in SN table */ ntime = doMovie (myInput, inData, NULL, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Create output image */ outImage = setOutput (myInput, ntime, inData, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Process */ doMovie (myInput, inData, outImage, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* History */ IonMovieHistory (myInput, inData, outImage, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* cleanup */ myInput = ObitInfoListUnref(myInput); /* delete input list */ inData = ObitUnref(inData); outImage = ObitUnref(outImage); /* Shutdown Obit */ exit: ObitReturnDumpRetCode (ierr, outfile, myOutput, err); /* Final output */ myOutput = ObitInfoListUnref(myOutput); /* delete output list */ mySystem = ObitSystemShutdown (mySystem); return ierr; } /* end of main */
sBool doProcess() { makeNormalMap(data->data, getInputData(0)->data, data->w, data->h, params[0].floatv); return sTRUE; }
int main ( int argc, char **argv ) /*----------------------------------------------------------------------- */ /* Obit task to copy tables arrached to ObitData objects */ /*----------------------------------------------------------------------- */ { oint ierr = 0; ObitSystem *mySystem= NULL; ObitData *inData = NULL, *outData = NULL; ObitErr *err= NULL; /* Startup - parse command line */ err = newObitErr(); myInput = TabCopyIn (argc, argv, err); if (err->error) {ierr = 1; ObitErrLog(err); goto exit;} /* Initialize logging */ ObitErrInit (err, (gpointer)myInput); ObitErrLog(err); /* show any error messages on err */ if (ierr!=0) return 1; /* Initialize Obit */ mySystem = ObitSystemStartup (pgmName, pgmNumber, AIPSuser, nAIPS, AIPSdirs, nFITS, FITSdirs, (oint)TRUE, (oint)FALSE, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Digest input */ digestInputs(myInput, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Get input data */ inData = getInputData (myInput, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Get output data */ outData = getOutputData (myInput, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Copy selected tables */ TabCopyCopy (myInput, inData, outData, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* Write history */ TabCopyHistory (myInput, inData, outData, err); if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* show any messages and errors */ if (err->error) ierr = 1; ObitErrLog(err); if (ierr!=0) goto exit; /* cleanup */ myInput = ObitInfoListUnref(myInput); inData = ObitUnref(inData); outData = ObitUnref(outData); /* Shutdown Obit */ exit: ObitReturnDumpRetCode (ierr, outfile, myOutput, err); /* Final output */ myOutput = ObitInfoListUnref(myOutput); mySystem = ObitSystemShutdown (mySystem); return ierr; } /* end of main */
void TestDevice::pushInput(const std::string& data) { getInputData().strings().set("helloWorld", data); pushInput(); }