Real bindX(Real x) const { if(x < xMin()) return xMin(); if (x > xMax()) return xMax(); return x; }
point2 poly2::RandInPoly() const { Double dx = xMax() - xMin(); Double dy = yMax() - yMin(); Double range = max(dx,dy); // VS2008 // rejection sampling logic point2 p0; do { Double x = xMin() + range*RandU(); Double y = yMin() + range*RandU(); p0 = point2(x,y); } while (!PointInPoly(p0)); return p0; }
Evaluation eval(const Evaluation& x, const Evaluation& y) const { typedef MathToolbox<Evaluation> Toolbox; #ifndef NDEBUG if (!applies(x,y)) { OPM_THROW(NumericalProblem, "Attempt to get tabulated value for (" << x << ", " << y << ") on a table of extend " << xMin() << " to " << xMax() << " times " << yMin() << " to " << yMax()); }; #endif Evaluation alpha = xToI(x); Evaluation beta = yToJ(y); unsigned i = std::max(0U, std::min(static_cast<unsigned>(numX()) - 2, static_cast<unsigned>(Toolbox::value(alpha)))); unsigned j = std::max(0U, std::min(static_cast<unsigned>(numY()) - 2, static_cast<unsigned>(Toolbox::value(beta)))); alpha -= i; beta -= j; // bi-linear interpolation const Evaluation& s1 = getSamplePoint(i, j)*(1.0 - alpha) + getSamplePoint(i + 1, j)*alpha; const Evaluation& s2 = getSamplePoint(i, j + 1)*(1.0 - alpha) + getSamplePoint(i + 1, j + 1)*alpha; return s1*(1.0 - beta) + s2*beta; }
void BinnedMap::save(QTextStream& ts, const QString& indent) { QString l2 = indent + " "; ts << indent << "<plugin name=\"Binned Map\">" << endl; ts << l2 << "<tag>" << QStyleSheet::escape(tagName()) << "</tag>" << endl; for (KstVectorMap::Iterator i = _inputVectors.begin(); i != _inputVectors.end(); ++i) { ts << l2 << "<ivector name=\"" << QStyleSheet::escape(i.key()) << "\">" << QStyleSheet::escape(i.data()->tagName()) << "</ivector>" << endl; } for (KstMatrixMap::Iterator i = _outputMatrices.begin(); i != _outputMatrices.end(); ++i) { ts << l2 << "<omatrix name=\"" << QStyleSheet::escape(i.key()); ts << "\">" << QStyleSheet::escape(i.data()->tagName()) << "</omatrix>" << endl; } ts << 12 << "<minX>" << xMin() << "</minX>" << endl; ts << 12 << "<maxX>" << xMax() << "</maxX>" << endl; ts << 12 << "<minY>" << yMin() << "</minY>" << endl; ts << 12 << "<maxY>" << yMax() << "</maxY>" << endl; ts << 12 << "<nX>" << nX() << "</nX>" << endl; ts << 12 << "<nY>" << nY() << "</nY>" << endl; if (autoBin()) { ts << 12 << "<autoBin/>" << endl; } ts << indent << "</plugin>" << endl; }
void QslRectLabel::paint(QPainter *painter) { QslRectScale *scale = static_cast<QslRectScale*>(this->scale()); painter->setPen(m->pen); painter->drawText(scale->mapX(xMin()), scale->mapY(yMin()), text()); }
QString Histogram::descriptionTip() const { QString tip; tip = tr("Histogram: %1").arg(Name()); if (realTimeAutoBin()) { tip+= tr("\n Auto-bin"); } else { tip += tr("\n %1 bins from %2 to %3").arg(numberOfBins()).arg(xMin()).arg(xMax()); } tip += tr("\nInput: %1").arg(_inputVectors[RAWVECTOR]->descriptionTip()); return tip; }
void ComplexPlotter::doRepaint() { setEnabledThreadStuff(false); mRepaintEnabled = true; resizeImage(); // call through to the superclass handler mStopwatch->start(); for(int i=mP.mNThreads-1; i>=0; i--) // paintThreads[i]->setPlotter(this); paintThreads[i]->render(mP, computeCSParameters(mLabel), xMin(), yMin()); qDebug() << "started " << mP.mNThreads << " threads."; }
BoxesSystem::BoxesSystem(mat& box_centers, mat& box_dims, const ObsType obs_type, const CostType cost_type, bool use_casadi) { this->init_dims(); mat xMin(X_DIM, 1, fill::ones), xMax(X_DIM, 1, fill::ones); mat uMin(U_DIM, 1, fill::ones), uMax(U_DIM, 1, fill::ones); xMin *= -3; xMax *= 3; uMin *= -.25; uMax *= .25; mat R = 1e-1*eye<mat>(N*R_DIM, N*R_DIM); this->init(box_centers, box_dims, obs_type, cost_type, use_casadi, xMin, xMax, uMin, uMax, R); }
BoxesSystem::BoxesSystem(mat& box_centers, mat& box_dims, const ObsType obs_type, const CostType cost_type, bool use_casadi, int T, int M, int N, double DT, int X_DIM, int U_DIM, int Z_DIM, int Q_DIM, int R_DIM) { this->init_dims(T, M, N, DT, X_DIM, U_DIM, Z_DIM, Q_DIM, R_DIM); mat xMin(X_DIM, 1, fill::ones), xMax(X_DIM, 1, fill::ones); mat uMin(U_DIM, 1, fill::ones), uMax(U_DIM, 1, fill::ones); xMin *= -3; xMax *= 3; uMin *= -.25; uMax *= .25; mat R = 1e-1*eye<mat>(N*R_DIM, N*R_DIM); this->init(box_centers, box_dims, obs_type, cost_type, use_casadi, xMin, xMax, uMin, uMax, R); }
BoxesSystem::BoxesSystem() { this->init_dims(); mat box_centers(N*X_DIM, 1, fill::zeros); mat box_dims(N*X_DIM, 1, fill::ones); ObsType obs_type = ObsType::distance; CostType cost_type = CostType::entropy; bool use_casadi = false; mat xMin(X_DIM, 1, fill::ones), xMax(X_DIM, 1, fill::ones); mat uMin(U_DIM, 1, fill::ones), uMax(U_DIM, 1, fill::ones); xMin *= -3; xMax *= 3; uMin *= -.25; uMax *= .25; mat R = 1e-1*eye<mat>(N*R_DIM, N*R_DIM); this->init(box_centers, box_dims, obs_type, cost_type, use_casadi, xMin, xMax, uMin, uMax, R); }
double GeomGlut::findSmartStepX( double workingMinX, double workingMaxX ) { double ratio = (xMax()-xMin())/((workingMaxX-workingMinX)*(double)winFuncPixels.x); //cout << "ratio: " << ratio << endl; return( ratio ); }
int operator< (const Record& other) const {return xMin(0) < other.xMin(0); }
Box <DIMENSION, ElementT> intersectBox (Box <DIMENSION, ElementT> box1, Box <DIMENSION, ElementT> box2) { return Box <DIMENSION, ElementT> (xMax (box1.corner1, box2.corner1), xMin (box1.corner2, box2.corner2)); }
bool applies(const Evaluation& x, const Evaluation& y) const { return xMin() <= x && x <= xMax() && yMin() <= y && y <= yMax(); }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Read in the existing solution files. Info << "Reading field U" << endl; volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); Info << "Reading field T" << endl; volScalarField T ( IOobject ( "T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); Info << "Reading field p_rgh" << endl; volScalarField p_rgh ( IOobject ( "p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); // Compute the velocity flux at the faces. This is needed // by the laminar transport model. Info<< "Creating/Calculating face flux field, phi..." << endl; surfaceScalarField phi ( IOobject ( "phi", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), linearInterpolate(U) & mesh.Sf() ); // Read the gravitational acceleration. This is needed // for calculating dp/dn on boundaries. Info << "Reading gravitational acceleration..." << endl; uniformDimensionedVectorField g ( IOobject ( "g", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); // Read the value of TRef in the transportProperties file. singlePhaseTransportModel laminarTransport(U, phi); dimensionedScalar TRef(laminarTransport.lookup("TRef")); // Use Tref and the T field to compute rhok, which is needed // to calculate dp/dn on boundaries. Info<< "Creating the kinematic density field, rhok..." << endl; volScalarField rhok ( IOobject ( "rhok", runTime.timeName(), mesh ), 1.0 - (T - TRef)/TRef ); // Get access to the input dictionary. IOdictionary setFieldsABLDict ( IOobject ( "setFieldsABLDict", runTime.time().system(), runTime, IOobject::MUST_READ, IOobject::NO_WRITE ) ); // Read in the setFieldsABLDict entries. word velocityInitType(setFieldsABLDict.lookup("velocityInitType")); word temperatureInitType(setFieldsABLDict.lookup("temperatureInitType")); word tableInterpTypeU(setFieldsABLDict.lookupOrDefault<word>("tableInterpTypeU","linear")); word tableInterpTypeT(setFieldsABLDict.lookupOrDefault<word>("tableInterpTypeT","linear")); scalar deltaU(setFieldsABLDict.lookupOrDefault<scalar>("deltaU",1.0)); scalar deltaV(setFieldsABLDict.lookupOrDefault<scalar>("deltaV",1.0)); scalar zPeak(setFieldsABLDict.lookupOrDefault<scalar>("zPeak",0.03)); scalar Uperiods(setFieldsABLDict.lookupOrDefault<scalar>("Uperiods",4)); scalar Vperiods(setFieldsABLDict.lookupOrDefault<scalar>("Vperiods",4)); scalar xMin(setFieldsABLDict.lookupOrDefault<scalar>("xMin",0.0)); scalar yMin(setFieldsABLDict.lookupOrDefault<scalar>("yMin",0.0)); scalar zMin(setFieldsABLDict.lookupOrDefault<scalar>("zMin",0.0)); scalar xMax(setFieldsABLDict.lookupOrDefault<scalar>("xMax",3000.0)); scalar yMax(setFieldsABLDict.lookupOrDefault<scalar>("yMax",3000.0)); scalar zMax(setFieldsABLDict.lookupOrDefault<scalar>("zMax",1000.0)); scalar zRef(setFieldsABLDict.lookupOrDefault<scalar>("zRef",600.0)); bool useWallDistZ(setFieldsABLDict.lookupOrDefault<bool>("useWallDistZ",false)); bool scaleVelocityWithHeight(setFieldsABLDict.lookupOrDefault<bool>("scaleVelocityWithHeight",false)); scalar zInversion(setFieldsABLDict.lookupOrDefault<scalar>("zInversion",600.0)); scalar Ug(setFieldsABLDict.lookupOrDefault<scalar>("Ug",15.0)); scalar UgDir(setFieldsABLDict.lookupOrDefault<scalar>("UgDir",270.0)); scalar Tbottom(setFieldsABLDict.lookupOrDefault<scalar>("Tbottom",300.0)); scalar Ttop(setFieldsABLDict.lookupOrDefault<scalar>("Ttop",304.0)); scalar dTdz(setFieldsABLDict.lookupOrDefault<scalar>("dTdz",0.003)); scalar widthInversion(setFieldsABLDict.lookupOrDefault<scalar>("widthInversion",80.0)); scalar TPrimeScale(setFieldsABLDict.lookupOrDefault<scalar>("TPrimeScale",0.0)); scalar z0(setFieldsABLDict.lookupOrDefault<scalar>("z0",0.016)); scalar kappa(setFieldsABLDict.lookupOrDefault<scalar>("kappa",0.40)); List<List<scalar> > profileTable(setFieldsABLDict.lookup("profileTable")); bool updateInternalFields(setFieldsABLDict.lookupOrDefault<bool>("updateInternalFields",true)); bool updateBoundaryFields(setFieldsABLDict.lookupOrDefault<bool>("updateBoundaryFields",true)); // Change the table profiles from scalar lists to scalar fields scalarField zProfile(profileTable.size(),0.0); scalarField UProfile(profileTable.size(),0.0); scalarField VProfile(profileTable.size(),0.0); scalarField TProfile(profileTable.size(),0.0); forAll(zProfile,i) { zProfile[i] = profileTable[i][0]; UProfile[i] = profileTable[i][1]; VProfile[i] = profileTable[i][2]; TProfile[i] = profileTable[i][3]; }
long double GeomGlut::findSmartStepX( long double workingMinX, long double workingMaxX ) { long double ratio = (xMax()-xMin())/((workingMaxX-workingMinX)*static_cast<long double>(winFuncPixels.x)); return( ratio ); }
void AiSelector::updateAi() { if (ui.checkBox->checkState() == Qt::Checked) { QImage *ai = previewHammingAiEdges(ui.previewLabel->preview(), new std::vector<double>(*d), ui.previewLabel->borders(), xMin(), xMax(), hammingNet(), thold(), blur()); ui.previewLabel->setPixmap(QPixmap::fromImage(*ai)); delete ai; } }
/*! * \brief Return the position on the x-axis of the i-th interval. */ Scalar iToX(unsigned i) const { assert(0 <= i && i < numX()); return xMin() + i*(xMax() - xMin())/(numX() - 1); }
Evaluation xToI(const Evaluation& x) const { return (x - xMin())/(xMax() - xMin())*(numX() - 1); }
float xMiddle(unsigned fVar) const {return 0.5*(xMin(fVar)+xMax(fVar));}
float BoxRange::xGridUnit() { return computeGridUnit(Axis::X, xMin(), xMax()); }
Box <DIMENSION, ElementT> enclosingBox (Box <DIMENSION, ElementT> box1, Box <DIMENSION, ElementT> box2) { return Box <DIMENSION, ElementT> (xMin (box1.corner1, box2.corner1), xMax (box1.corner2, box2.corner2)); }