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


C++ TFltV::Empty方法代码示例

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


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

示例1: AddFtr

void TMultinomial::AddFtr(const TStrV& StrV, const TFltV& FltV, TIntFltKdV& SpV) const {
    // make sure we either do not have explicit values, or their dimension matches with string keys
    EAssertR(FltV.Empty() || (StrV.Len() == FltV.Len()), "TMultinomial::AddFtr:: String and double values not aligned");
    // generate internal feature vector
    SpV.Gen(StrV.Len(), 0);
    for (int StrN = 0; StrN < StrV.Len(); StrN++) {
        const int FtrId = FtrGen.GetFtr(StrV[StrN]);
        // only use features we've seen during updates
        if (FtrId != -1) {
            const double Val = FltV.Empty() ? 1.0 : FltV[StrN].Val;
            if (Val > 1e-16) { SpV.Add(TIntFltKd(FtrId, Val)); }
        }
    }
    SpV.Sort();
    // merge elements with the same id
    int GoodSpN = 0;
    for (int SpN = 1; SpN < SpV.Len(); SpN++) {
        if (SpV[GoodSpN].Key == SpV[SpN].Key) {
            // repetition of previous id, sum counts
            SpV[GoodSpN].Dat += SpV[SpN].Dat;
        } else {
            // increase the pointer to the next good position
            GoodSpN++;
            // and move the new value down to the good position
            SpV[GoodSpN] = SpV[SpN];
        }
    }
    // truncate the vector
    SpV.Trunc(GoodSpN + 1);
    // replace values with 1 if needed
    if (IsBinary()) { for (TIntFltKd& Sp : SpV) { Sp.Dat = 1.0; } }
    // final normalization, if needed
    if (IsNormalize()) { TLinAlg::Normalize(SpV); }    
}
开发者ID:joaopitacosta,项目名称:qminer,代码行数:34,代码来源:ftrgen.cpp

示例2: GetErr

double TEpidemModel::GetErr(const TFltV& TrueV, const TFltV& SimV, const int& SimT0) { 
  if (SimV.Empty() || TrueV.Empty()) { return -1.0; }
  double Err = 0.0;
  double S=0;
  for (int t=0; t < TrueV.Len(); t++) {
    if (t-SimT0 >= 0) { S = SimV[t-SimT0]; } else { S = 0; }
    Err += TMath::Sqr(TrueV[t]-S);
  }
  if (Err <= 0) { Err = TFlt::Mx; }
  return Err;
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:11,代码来源:sir.cpp

示例3: ConjugGrad

static void ConjugGrad(const TMatrix& Matrix, const TFltV& b, TFltV& x, 
        const int& CGMxIter, const double& RelErr, const TFltV& x0) {

    // prepare start vector
    x.Gen(Matrix.GetCols());
    if (x0.Empty()) { x.PutAll(0.0); }
    else { x = x0; }
    // do the magic
}
开发者ID:Accio,项目名称:snap,代码行数:9,代码来源:mkcca.cpp

示例4: Predict

TFltV KalmanFilter::Predict(TFltV control) {
	
	// update the state: x'(k) = A * x(k)
	TLinAlg::Multiply(transitionMatrix, statePost, statePre);

	// x'(k) = x'(k) + B * u(k)
	if (!control.Empty()) {
		TLinAlg::Multiply(controlMatrix, control, temp1V);
		TLinAlg::AddVec(1.0, statePre, temp1V, temp2V);
	}

	// update error covariance matrices: temp1 = A * P(k)
	TLinAlg::Multiply(transitionMatrix, errorCovPost, temp1VV);

	// P'(k) = temp1 * At + Q
	TLinAlg::Gemm(1.0, temp1VV, transitionMatrix, 1.0, processNoiseCov, errorCovPre, TLinAlg::GEMM_B_T);
	
	// return statePre
	return statePre;

}
开发者ID:klemenkenda,项目名称:NRG4Cast,代码行数:21,代码来源:kalman.cpp

示例5: GetInvParticipRat

void GetInvParticipRat(const PUNGraph& Graph, int MaxEigVecs, int TimeLimit, TFltPrV& EigValIprV) {
  TUNGraphMtx GraphMtx(Graph);
  TFltVV EigVecVV;
  TFltV EigValV;
  TExeTm ExeTm;
  if (MaxEigVecs<=1) { MaxEigVecs=1000; }
  int EigVecs = TMath::Mn(Graph->GetNodes(), MaxEigVecs);
  printf("start %d vecs...", EigVecs);
  try {
    TSparseSVD::Lanczos2(GraphMtx, EigVecs, TimeLimit, ssotFull, EigValV, EigVecVV, false);
  } catch(...) {
    printf("\n  ***EXCEPTION:  TRIED %d GOT %d values** \n", EigVecs, EigValV.Len()); }
  printf("  ***TRIED %d GOT %d values in %s\n", EigVecs, EigValV.Len(), ExeTm.GetStr());
  TFltV EigVec;
  EigValIprV.Clr();
  if (EigValV.Empty()) { return; }
  for (int v = 0; v < EigVecVV.GetCols(); v++) {
    EigVecVV.GetCol(v, EigVec);
    EigValIprV.Add(TFltPr(EigValV[v], GetInvParticipRat(EigVec)));
  }
  EigValIprV.Sort();
}
开发者ID:Networks-Learning,项目名称:infopath,代码行数:22,代码来源:gsvd.cpp

示例6: 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);
}
开发者ID:Accio,项目名称:snap,代码行数:22,代码来源:statplot.cpp


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