inline void pushdown(int x, int l, int r) { if(tr[x].tag < INF) { int mid = (l+r)>>1; mdf(x<<1, l, mid, tr[x].tag); mdf(x<<1|1, mid+1, r, tr[x].tag); tr[x].tag = INF; }
inline void access() { for(node *p = this, *q = 0; p; q = p, p = p->fa) { p->splay(); if(p->c[1]) mdf(p->c[1]->anc, 1); if(q) mdf(q->anc, -1); p->setc(q, 1); } }
ScatterResidual<PHX::MyTraits::Jacobian, Traits>:: ScatterResidual(const Teuchos::ParameterList& p) { scatter_operation = Teuchos::rcp(new PHX::Tag<ScalarT>("Scatter",p.get< Teuchos::RCP<PHX::DataLayout> >("Dummy Data Layout"))); const std::vector<std::string>& names = *(p.get< Teuchos::RCP< std::vector<std::string> > >("Residual Names")); Teuchos::RCP<PHX::DataLayout> dl = p.get< Teuchos::RCP<PHX::DataLayout> >("Data Layout"); f = p.get< Teuchos::RCP<Epetra_Vector> >("Residual Vector"); if (p.template isType< Teuchos::RCP<Epetra_VbrMatrix> >("Jacobian Matrix")) Jac = p.template get< Teuchos::RCP<Epetra_VbrMatrix> >("Jacobian Matrix"); val.resize(names.size()); for (std::size_t eq = 0; eq < names.size(); ++eq) { PHX::MDField<ScalarT,Cell,Node> mdf(names[eq],dl); val[eq] = mdf; this->addDependentField(val[eq]); } this->addEvaluatedField(*scatter_operation); this->setName("Scatter Residual(Jacobian)"); }
void mdf(int x, int l, int r, int v) { if(v >= tr[x].max) return ; if(v <= tr[x].max && v > tr[x].max2) { tr[x].sum -= 1ll*(tr[x].max-v)*tr[x].num; tr[x].max = v, tr[x].tag = v; } else if(v <= tr[x].max2) { if(l == r) { tr[x] = data(v, 1, -1, INF, v); return ; } int mid = (l+r)>>1; mdf(x<<1, l, mid, v); mdf(x<<1|1, mid+1, r, v); pushup(x); } }
void teste_integral_2(IntegralImage ii){ for(register int i=0;i<4;++i){ for(register int j=0;j<4;++j){ printf("%lu ",ii.data()[i][j]); } printf("\n"); } Point ardis; ardis.y = 24; ardis.x = 24; MaskTwoHorizontalFactory m2hf(ardis,1,1,0,2,1); MaskTwoVerticalFactory m2vf(ardis,1,1,0,1,2); MaskThreeHorizontalFactory m3hf(ardis,1,1,0,3,1); MaskThreeVerticalFactory m3vf(ardis,1,1,0,1,3); MaskDiagonalFactory mdf(ardis,1,1,0,2,2); FMF factories[5]; std::vector<FeatureMask> _facesFeatures; factories[0] = m2hf; factories[1] = m2vf; factories[2] = m3hf; factories[3] = m3vf; factories[4] = mdf; int counter=0; for(int i=0;i<5;i++){ while( factories[i].hasNext()==1 ){ _facesFeatures.push_back( factories[i].next(counter++) ); } } printf("%d\n", _facesFeatures.size()); FeatureMask fm = m2hf.next(); printf("M2HF: %lu\n",ii.filter( fm ) ); fm = m2vf.next(); printf("M2VF: %lu\n",ii.filter( fm ) ); fm = m3hf.next(); printf("M3HF: %lu\n",ii.filter( fm ) ); fm = m3vf.next(); printf("M3VF: %lu\n",ii.filter( fm ) ); fm = mdf.next(); printf("MDF: %lu\n",ii.filter( fm ) ); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void StatsGenMDFWidget::updateMDFPlot(QVector<float>& odf) { int err = 0; int size = 100000; // These are the input vectors QVector<float> angles; QVector<float> axes; QVector<float> weights; angles = m_MDFTableModel->getData(SGMDFTableModel::Angle); weights = m_MDFTableModel->getData(SGMDFTableModel::Weight); axes = m_MDFTableModel->getData(SGMDFTableModel::Axis); // These are the output vectors QVector<float> x; QVector<float> y; if ( Ebsd::CrystalStructure::Cubic_High == m_CrystalStructure ) { // Allocate a new vector to hold the mdf data QVector<float> mdf(CubicOps::k_MdfSize); // Calculate the MDF Data using the ODF data and the rows from the MDF Table model Texture::CalculateMDFData<float, CubicOps>(angles.data(), axes.data(), weights.data(), odf.data(), mdf.data(), static_cast<size_t>(angles.size())); // Now generate the actual XY point data that gets plotted. int npoints = 13; x.resize(npoints); y.resize(npoints); err = StatsGen::GenCubicMDFPlotData(mdf.data(), x.data(), y.data(), npoints, size); if (err < 0) { return; } } else if ( Ebsd::CrystalStructure::Hexagonal_High == m_CrystalStructure ) { // Allocate a new vector to hold the mdf data QVector<float> mdf(HexagonalOps::k_MdfSize); // Calculate the MDF Data using the ODF data and the rows from the MDF Table model Texture::CalculateMDFData<float, HexagonalOps>(angles.data(), axes.data(), weights.data(), odf.data(), mdf.data(), static_cast<size_t>(angles.size())); // Now generate the actual XY point data that gets plotted. int npoints = 20; x.resize(npoints); y.resize(npoints); err = StatsGen::GenHexMDFPlotData(mdf.data(), x.data(), y.data(), npoints, size); if (err < 0) { return; } } QwtArray<double> xD(static_cast<int>(x.size())); QwtArray<double> yD(static_cast<int>(x.size())); for (qint32 i = 0; i < x.size(); ++i) { xD[i] = static_cast<double>(x.at(i)); yD[i] = static_cast<double>(y.at(i)); } // This will actually plot the XY data in the Qwt plot widget QwtPlotCurve* curve = m_PlotCurve; #if QWT_VERSION >= 0x060000 curve->setSamples(xD, yD); #else curve->setData(xD, yD); #endif QColor color = QColor("DodgerBlue"); curve->setPen(color, 2); curve->setRenderHint( QwtPlotItem::RenderAntialiased, true ); curve->setStyle(QwtPlotCurve::Lines); QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::white ), QPen( color, 2 ), QSize( 8, 8 ) ); curve->setSymbol( symbol ); curve->attach(m_MDFPlot); m_MDFPlot->replot(); }
bool InvertedIndex::ReadMetaDataFile(bool force, bool nodata, bool wrlocked, string filename, size_t maxn) { bool debug = false; string msg = "Index::ReadMetaDataFile() : "; if (force || /*nodata ||*/ wrlocked) { cerr << "Index::ReadMetaDataFile(" << force << ", " << nodata << ", " << wrlocked << ")" << endl; return ShowError(msg+"strange arguments"); } // obs! feature_target should be solved here! if (filename=="") filename = metfile_str; ifstream met(filename.c_str()); if (!met) return ShowError(msg+"could not read <"+filename+">"); FloatVectorSet cols(DataSetSize()); string comment = "Automatically generated meta data\n" "Field names (components):\n"; Tic("ReadMetaDataFile"); size_t linecount=0; for (;;) { string line; getline(met, line); if (!met) break; if (line.find_first_not_of(" \t")==string::npos) continue; if (line[0]=='#') { if (line.find("indices")!=string::npos) binary_classindices = true; continue; } int i = line.size()-1; while (i>=0 && isspace(line[i])) line.erase(i--); Tic("GroundTruthExpression"); bool expand = false; // was true (and much slower) until 5.4.2006 ground_truth ivec = db->GroundTruthExpression(line, feature_target, -1, expand); Tac("GroundTruthExpression"); if (debug) db->GroundTruthSummaryTable(ivec); if (ivec.empty()) { meta_data_fields.clear(); return ShowError(msg+"<"+filename+"> field \"", line, "\" not known"); } if (!nodata) { Tic("loop-1"); FloatVector fvec(ivec.size()); for (int j=0; j<fvec.Length(); j++) fvec[j] = ivec[j]; cols.AppendCopy(fvec); linecount++; Tac("loop-1"); } int ncols = 1; pair<string,int> mdf(line, ncols); meta_data_fields.push_back(mdf); stringstream ss; ss << " " << line << " (" << ncols << ")";;; comment += ss.str(); // cout << "!!! [" << line << "] OK !!!" << endl; if (maxn != 0 && linecount >= maxn) break; } if (!nodata) { bool check_type = true, check_restr = true; // added 3.5.2006 Tic("loop-2"); data.Delete(); data.VectorLength(cols.Nitems()); for (int i=0; i<cols.VectorLength(); i++) { if (check_type && !db->ObjectsTargetTypeContains(i, feature_target)) continue; if (check_restr && !db->OkWithRestriction(i)) continue; FloatVector v(cols.Nitems(), NULL, db->LabelP(i)); v.Number(i); for (int j=0; j<v.Length(); j++) v[j] = cols[j][i]; data.AppendCopy(v); } data.SetDescription(comment.c_str()); Tac("loop-2"); } Tac("ReadMetaDataFile"); string log = "Read meta data file <"+ShortFileName(filename)+">"; if (!nodata) log += " and processed to "+ToStr(data.Nitems())+" vectors of length "+ ToStr(data.VectorLength()); else log += " without processing"; WriteLog(log); return true; }