当前位置: 首页>>代码示例>>C++>>正文


C++ TFltPrV::Len方法代码示例

本文整理汇总了C++中TFltPrV::Len方法的典型用法代码示例。如果您正苦于以下问题:C++ TFltPrV::Len方法的具体用法?C++ TFltPrV::Len怎么用?C++ TFltPrV::Len使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TFltPrV的用法示例。


在下文中一共展示了TFltPrV::Len方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CalcEffDiam

double CalcEffDiam(const TFltPrV& DistNbrsCdfV, const double& Percentile) {
  TIntFltKdV KdV(DistNbrsCdfV.Len(), 0);
  for (int i = 0; i < DistNbrsCdfV.Len(); i++) {
    KdV.Add(TIntFltKd(int(DistNbrsCdfV[i].Val1()), DistNbrsCdfV[i].Val2));
  }
  return CalcEffDiam(KdV, Percentile);
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:7,代码来源:anf.cpp

示例2: AddErrBar

int TGnuPlot::AddErrBar(const TFltPrV& XYValV, const TFltV& DeltaYV, const TStr& Label) {
  TFltKdV XYFltValV(XYValV.Len(), 0);
  for (int i = 0; i < XYValV.Len(); i++) {
    XYFltValV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2));
  }
  return AddErrBar(XYFltValV, DeltaYV, Label);
}
开发者ID:mkrnc,项目名称:snap,代码行数:7,代码来源:gnuplot.cpp

示例3: AddPlot

int TGnuPlot::AddPlot(const TFltPrV& XYValV, const TGpSeriesTy& SeriesTy, const TStr& Label, const TStr& Style) {
  TFltKdV XYFltValV(XYValV.Len(), 0);
  for (int i = 0; i < XYValV.Len(); i++) {
    XYFltValV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2));
  }
  return AddPlot(XYFltValV, SeriesTy, Label, Style);
}
开发者ID:mkrnc,项目名称:snap,代码行数:7,代码来源:gnuplot.cpp

示例4: Normalize

void TGUtil::Normalize(TFltPrV& PdfV) {
  double Sum = 0.0;
  for (int i = 0; i < PdfV.Len(); i++) {
    Sum += PdfV[i].Val2; }
  if (Sum <= 0.0) { return; }
  for (int i = 0; i < PdfV.Len(); i++) {
    PdfV[i].Val2 /= Sum; }
}
开发者ID:hmipakchi,项目名称:FinalYearProject,代码行数:8,代码来源:util.cpp

示例5: IAssert

void TSirSR2Model::SetMediaBlogV(const TFltPrV& _MediaV, const TFltPrV& _BlogV) {
  IAssert(_MediaV.Len() == _BlogV.Len());
  MediaV.Clr(false);  BlogV.Clr(false);
  for (int i = 0; i < _MediaV.Len(); i++) {
    MediaV.Add(_MediaV[i].Val2);
    BlogV.Add(_BlogV[i].Val2);
  }
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:8,代码来源:sir.cpp

示例6: MakeExpBins

void TGnuPlot::MakeExpBins(const TFltPrV& XYValV, TFltPrV& ExpXYValV, const double& BinFactor, const double& MinYVal) {
  TFltKdV KdV(XYValV.Len(), 0), OutV;
  for (int i = 0; i < XYValV.Len(); i++) {
    KdV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2)); }
  KdV.Sort();
  TGnuPlot::MakeExpBins(KdV, OutV, BinFactor, MinYVal);
  ExpXYValV.Gen(OutV.Len(), 0);
  for (int i = 0; i < OutV.Len(); i++) {
    ExpXYValV.Add(TFltPr(OutV[i].Key, OutV[i].Dat)); }
}
开发者ID:mkrnc,项目名称:snap,代码行数:10,代码来源:gnuplot.cpp

示例7: GetNEFromAccDistr

void GetNEFromAccDistr(const TFltPrV& deg, int& nodes, int& edges){
    double nodesD = deg[0].Val2.Val, edgesD = 0;
    for (int i = 0; i < deg.Len(); i++){
        if (i == deg.Len()-1)
            edgesD += deg[i].Val1.Val * deg[i].Val2.Val;
        else edgesD += deg[i].Val1.Val * (deg[i].Val2.Val - deg[i+1].Val2.Val);
    }
    nodes = static_cast<int>(nodesD);
    edges = static_cast<int>(edgesD);
    //	edges /= 2; as Deg = inDeg + outDeg
}
开发者ID:KronGen,项目名称:KronTest,代码行数:11,代码来源:InOut.cpp

示例8: GetCumDistr

void GetCumDistr(const TFltPrV& nonCum, TFltPrV& res){
	for (int i = nonCum.Len() - 1; i >=0; i--){
		TFlt count;
		if (i == nonCum.Len() - 1)
			count = nonCum[i].Val2.Val;
		else
			count = nonCum[i].Val2.Val + res[res.Len()-1].Val2.Val;
		TFltPr val(nonCum[i].Val1, count);
		res.Add(val);
	}
	res.Sort();
}
开发者ID:kbochenina,项目名称:Snap,代码行数:12,代码来源:Plot.cpp

示例9: exp

// MLE power-coefficient
int TGnuPlot::AddPwrFit2(const int& PlotId, const TGpSeriesTy& SeriesTy, const double& MinX, const TStr& Style) {
  const TGpSeries& Plot = SeriesV[PlotId];
  if(Plot.XYValV.Empty()) return -1;
  const TFltKdV& XY = Plot.XYValV;
  // power fit
  TFltPrV XYPr;
  double MinY = TFlt::Mx;
  for (int s = 0; s < XY.Len(); s++) {
    if (XY[s].Key > 0.0) {
      XYPr.Add(TFltPr(XY[s].Key, XY[s].Dat));
      MinY = TMath::Mn(MinY, XY[s].Dat());
    }
  }
  if (XYPr.Empty()) return -1;
  MinY = TMath::Mn(1.0, MinY);
  // determine the sign of power coefficient
  double CoefSign = 0.0;
  { double A, B, R2, SigA, SigB, Chi2;
  TSpecFunc::PowerFit(XYPr, A, B, SigA, SigB, Chi2, R2);
  CoefSign = B > 0.0 ? +1.0 : -1.0; }
  const double PowerCf = CoefSign * TSpecFunc::GetPowerCoef(XYPr, MinX);
  int Mid = (int) exp(log((double)XYPr.Len())/2.0);
  if (Mid >= XYPr.Len()) { Mid = XYPr.Len()-1; }
  const double MidX = XYPr[Mid].Val1();
  const double MidY = XYPr[Mid].Val2();
  const double B = MidY / pow(MidX, PowerCf);
  TStr StyleStr=Style;
  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
  const int FitId = AddFunc(TStr::Fmt("%f*x**%f", B, PowerCf),
    SeriesTy, TStr::Fmt("MLE = x^{%.4g}", PowerCf), StyleStr);
  return FitId;
  /*SeriesV.Add();
  TGpSeries& NewPlot = SeriesV.Last();
  TFltKdV& XYFit = NewPlot.XYValV;
  XYFit.Gen(XYPr.Len(), 0);
  for (int s = 0; s < XYPr.Len(); s++) {
    const double XVal = XYPr[s].Val1;
    const double YVal = B * pow(XYPr[s].Val1(), PowerCf);
    if (YVal < MinY || XVal < MinX) continue;
    XYFit.Add(TFltKd(XVal, YVal));
  }
  NewPlot.Label = TStr::Fmt("PowerFit: %g", PowerCf);
  NewPlot.SeriesTy = SeriesTy;
  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
  else { NewPlot.WithStyle = Style; }
  return SeriesV.Len() - 1;*/
}
开发者ID:mkrnc,项目名称:snap,代码行数:48,代码来源:gnuplot.cpp

示例10: CalcAvgDiamPdf

double CalcAvgDiamPdf(const TFltPrV& DistNbrsPdfV) {
  double Paths=0, SumLen=0;
  for (int i = 0; i < DistNbrsPdfV.Len(); i++) {
    SumLen += DistNbrsPdfV[i].Val1 * DistNbrsPdfV[i].Val2;
    Paths += DistNbrsPdfV[i].Val2;
  }
  return SumLen/Paths;
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:8,代码来源:anf.cpp

示例11: ExpBinning

// CHECK
void ExpBinning(const TFltPrV& deg, TFltPrV& degSparse, const int& BinRadix){
	TFlt maxDeg(deg[deg.Len()-1].Val1.Val), minDeg(deg[0].Val1.Val);
	bool maxPowerReached = false;
	// idx - index of border, previdx - index of previous border
	int power = 0, previdx = 0, idx, binSize;
	TFltPr val;
	double binBorder = 0.0;
	while (binBorder <= minDeg)
		binBorder = pow(static_cast<double>(BinRadix), power++);

	TFltPr v(minDeg, deg[0].Val2.Val);
	degSparse.Add(v);

	bool isExact = false;
	while (!maxPowerReached){
		if (binBorder >= maxDeg){
			// when last element of deg was previous bin border
			if (previdx == deg.Len() - 1)
				break;
			// if we have another elements
			binBorder = maxDeg;
			maxPowerReached = true;
		}
		// find next element
		idx = FindVal1Elem(deg, binBorder, isExact);
		// if bin size == 0
		if (previdx + 1 == idx && !isExact)
			continue;
		if (!isExact)
			idx = idx - 1;
		double sum = 0.0;
		binSize = idx - previdx;
		for (int i = previdx + 1; i <= idx; i++){
			sum += deg[i].Val2.Val;
		}
		sum /= binSize;
		// if prevBinBorder was the smallest degree, it can be more than binBorder / BinRadix
		double SumBinBorder = previdx > 0 ? binBorder + static_cast<double>(binBorder) / BinRadix : binBorder + static_cast<double>(minDeg); 
		double avgDeg = SumBinBorder / 2.0;
		val.Val1 = avgDeg; val.Val2 = sum;
		degSparse.Add(val);
		previdx = idx;
		binBorder = pow(static_cast<double>(BinRadix), power++);
	}
}
开发者ID:kbochenina,项目名称:Snap,代码行数:46,代码来源:Plot.cpp

示例12: PlotInvParticipRat

// Inverse participation ratio: normalize EigVec to have L2=1 and then I=sum_k EigVec[i]^4
// see Spectra of "real-world" graphs: Beyond the semicircle law by Farkas, Derenyi, Barabasi and Vicsek
void PlotInvParticipRat(const PUNGraph& Graph, const int& MaxEigVecs, const int& TimeLimit, const TStr& FNmPref, TStr DescStr) {
  TFltPrV EigIprV;
  GetInvParticipRat(Graph, MaxEigVecs, TimeLimit, EigIprV);
  if (DescStr.Empty()) { DescStr = FNmPref; }
  if (EigIprV.Empty()) { DescStr+=". FAIL"; EigIprV.Add(TFltPr(-1,-1)); return; }
  TGnuPlot::PlotValV(EigIprV, "eigIPR."+FNmPref, TStr::Fmt("%s. G(%d, %d). Largest eig val = %f (%d values)",
    DescStr.CStr(), Graph->GetNodes(), Graph->GetEdges(), EigIprV.Last().Val1(), EigIprV.Len()),
    "Eigenvalue", "Inverse Participation Ratio of corresponding Eigenvector", gpsLog10Y, false, gpwPoints);
}
开发者ID:Accio,项目名称:snap,代码行数:11,代码来源:statplot.cpp

示例13: GetNodesEdgesCountFromDegDistr

void GetNodesEdgesCountFromDegDistr(const TFltPrV& deg, int& nodes, int& edges){
	double nodesD = 0, edgesD = 0;
	for (int i = 0; i < deg.Len(); i++){
		nodesD += deg[i].Val2.Val;
		edgesD += deg[i].Val1.Val * deg[i].Val2.Val;
	}
	nodes = static_cast<int>(nodesD);
	edges = static_cast<int>(edgesD);
//	edges /= 2; as Deg = inDeg + outDeg
}
开发者ID:kbochenina,项目名称:Snap,代码行数:10,代码来源:Plot.cpp

示例14: FindVal1Elem

int FindVal1Elem(const TFltPrV& vec, const TFlt& elem, bool& isExact){
	for (int i = 0; i < vec.Len(); i++){
		if (vec[i].Val1.Val == elem){
			isExact = true;
			return i;
		}
		if (vec[i].Val1.Val > elem){
			return i-1;
		}
	}
	return false;
}
开发者ID:kbochenina,项目名称:Snap,代码行数:12,代码来源:Plot.cpp

示例15: GetPoints

void GetPoints(const TFlt& maxDegLog, const TFlt& minDegLog, const int& NInt, const TFltPrV& base, TFltPrV& points){
	int beginIndex = 0;
	// ignore nodes with zero degree (for Kronecker graphs)
	/*if (base[0].Val1.Val != 0)
		points.Add(base[beginIndex]);
	else {
		points.Add(base[++beginIndex]);
	}*/
	points.Add(base[beginIndex]);
	TFlt baseMaxDeg = base[base.Len()-1].Val1.Val,
		baseMinDeg = base[beginIndex].Val1.Val;
	for (int i = beginIndex + 1; i < NInt; i++){
		// deg - degree to be found in base
		TFlt degRound (pow (10, minDegLog.Val + i * (maxDegLog.Val - minDegLog.Val) / NInt));
		TInt degInt(static_cast<int>(degRound.Val));
		TFlt deg(degInt);
		// if deg < baseMinDeg (for cases when baseMinDeg > minDeg)
		if (deg.Val <= baseMinDeg)
			continue;
		// if deg > baseMaxDeg, add last point and finish
		if (deg.Val >= baseMaxDeg){
			points.Add(base[base.Len()-1]);
			break;
		}
		// we have two cases: when we can find an exact value of deg, or when we have not this value
		bool isExact = false;
		int index = FindVal1Elem(base, deg, isExact);
		if (isExact){
			points.Add(base[index]);
		}
		else 
		{
			TFltPr x;
			x.Val1.Val = deg;
			x.Val2.Val = ( base[index].Val2.Val + base [index + 1].Val2.Val ) / 2;
			points.Add(x);
		}
	}
}
开发者ID:kbochenina,项目名称:Snap,代码行数:39,代码来源:Stat.cpp


注:本文中的TFltPrV::Len方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。