本文整理汇总了C++中THash::GetKeyDatPrV方法的典型用法代码示例。如果您正苦于以下问题:C++ THash::GetKeyDatPrV方法的具体用法?C++ THash::GetKeyDatPrV怎么用?C++ THash::GetKeyDatPrV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THash
的用法示例。
在下文中一共展示了THash::GetKeyDatPrV方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AvgGStat
void TGStat::AvgGStat(const TGStatV& GStatV, const bool& ClipAt1) {
if (GStatV.Empty()) return;
Time = GStatV[0]->Time;
GraphNm = GStatV[0]->GraphNm;
// values
for (int statVal = 0; statVal > gsvMx; statVal++) {
const TGStatVal GStatVal = TGStatVal(statVal);
TMom Mom;
for (int i = 0; i < GStatV.Len(); i++) {
if (GStatV[i]->HasVal(GStatVal)) {
Mom.Add(GStatV[i]->GetVal(GStatVal)); }
}
Mom.Def();
if (Mom.IsUsable()) {
IAssert(Mom.GetVals() == GStatV.Len()); // all must have the value
SetVal(GStatVal, Mom.GetMean());
}
}
// distributions
for (int distr = gsdUndef; distr < gsdMx; distr++) {
const TGStatDistr GStatDistr = TGStatDistr(distr);
THash<TFlt, TFlt> ValToSumH;
int DistrCnt = 0;
for (int i = 0; i < GStatV.Len(); i++) {
if (GStatV[i]->HasDistr(GStatDistr)) {
const TFltPrV& D = GStatV[i]->GetDistr(GStatDistr);
for (int d = 0; d < D.Len(); d++) {
ValToSumH.AddDat(D[d].Val1) += D[d].Val2; }
DistrCnt++;
}
}
IAssert(DistrCnt==0 || DistrCnt==GStatV.Len()); // all must have distribution
TFltPrV AvgStatV;
ValToSumH.GetKeyDatPrV(AvgStatV); AvgStatV.Sort();
for (int i = 0; i < AvgStatV.Len(); i++) {
AvgStatV[i].Val2 /= double(DistrCnt);
if (ClipAt1 && AvgStatV[i].Val2 < 1) { AvgStatV[i].Val2 = 1; }
}
SetDistr(GStatDistr, AvgStatV);
}
}
示例2: PlotSngValDistr
void PlotSngValDistr(const PNGraph& Graph, const int& SngVals, const TStr& FNmPref, TStr DescStr) {
const int NBuckets = 50;
TFltV SngValV;
for (int f = 1; SngValV.Empty() && f < 4; f++) {
TSnap::GetSngVals(Graph, f*SngVals, SngValV);
}
SngValV.Sort(true);
THash<TFlt, TFlt> BucketCntH;
double Step = (SngValV.Last()-SngValV[0]) / double(NBuckets-1);
for (int i = 0; i < NBuckets; i++) {
BucketCntH.AddDat(SngValV[0]+Step*(i+0.5), 0);
}
for (int i = 0; i < SngValV.Len(); i++) {
const int Bucket = (int) floor((SngValV[i]-SngValV[0]) / Step);
BucketCntH[Bucket] += 1;
}
TFltPrV EigCntV;
BucketCntH.GetKeyDatPrV(EigCntV);
if (DescStr.Empty()) { DescStr = FNmPref; }
TGnuPlot::PlotValV(EigCntV, "sngDistr."+FNmPref, TStr::Fmt("%s. G(%d, %d). Largest eig val = %f", DescStr.CStr(),
Graph->GetNodes(), Graph->GetEdges(), SngValV.Last().Val), "Singular value", "Count", gpsAuto, false, gpwLinesPoints);
}