本文整理汇总了C++中TFltV::Clr方法的典型用法代码示例。如果您正苦于以下问题:C++ TFltV::Clr方法的具体用法?C++ TFltV::Clr怎么用?C++ TFltV::Clr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFltV
的用法示例。
在下文中一共展示了TFltV::Clr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RungeKutta
void TEpidemModel::RungeKutta(const TFltV& y, const TFltV& dydx, double x, double h, TFltV& SirOutV) {
const int n = y.Len();
IAssert(y.Len() == n && dydx.Len() == n);
TFltV dym(n), dyt(n), yt(n);
int i;
double hh=h*0.5;
double h6=h/6.0;
double xh=x+hh;
for (i=0; i < n; i++) {
yt[i]=y[i]+hh*dydx[i];
}
GetDerivs(xh, yt, dyt);
for (i=0; i<n; i++) {
yt[i]=y[i]+hh*dyt[i];
}
GetDerivs(xh,yt,dym);
for (i=0; i<n; i++) {
yt[i]=y[i]+h*dym[i];
dym[i] += dyt[i];
}
GetDerivs(x+h,yt,dyt);
SirOutV.Clr(false);
for (i=0; i<n; i++) {
SirOutV.Add(y[i]+h6 * (dydx[i]+dyt[i]+2.0*dym[i]));
}
}
示例2: GetResults
void TNNet::GetResults(TFltV& ResultV) const{
ResultV.Clr(true, -1);
for(int NeuronN = 0; NeuronN < LayerV.Last().GetNeuronN() - 1; ++NeuronN){
ResultV.Add(LayerV.Last().GetOutVal(NeuronN));
}
}
示例3: GetParam
void TSirModel::GetParam(TFltV& ParamV) const {
ParamV.Clr(false);
ParamV.Add(N0);
ParamV.Add(I0);
ParamV.Add(Beta);
ParamV.Add(Gamma);
ParamV.Add(T0);
}
示例4: MakeExpBins
void TGUtil::MakeExpBins(const TFltV& YValV, TFltV& ExpYValV, const double& BinFactor) {
ExpYValV.Clr(true);
int prevI=0;
for (int i = 0; i < YValV.Len(); ) {
ExpYValV.Add(YValV[i]);
i = int(i*BinFactor);
if (i==prevI) { i++; }
prevI = i;
}
}
示例5: LoadTxt
void TEpidemModel::LoadTxt(const TStr& InFNm, const int& ColId, TFltV& ValV) {
ValV.Clr();
if (! TFile::Exists(InFNm)) {
printf("*** %s not found!\n", InFNm.CStr());
return;
}
TSsParser Ss(InFNm, ssfTabSep);
while (Ss.Next()) {
ValV.Add(Ss.GetFlt(ColId));
}
}
示例6: PermOutEdgeWgt
void TWgtNet::PermOutEdgeWgt() {
TFltV WgtV;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
WgtV.Clr(false);
for (int e = 0; e < NI.GetOutDeg(); e++) {
WgtV.Add(NI.GetOutEDat(e));
}
WgtV.Shuffle(TInt::Rnd);
for (int e = 0; e < NI.GetOutDeg(); e++) {
NI.GetOutEDat(e) = WgtV[e];
}
}
}
示例7:
void TSir2Model::GetParam(TFltV& ParamV) const {
ParamV.Clr(false);
ParamV.Add(N0M);
ParamV.Add(I0M);
ParamV.Add(N0B);
ParamV.Add(I0B);
ParamV.Add(T0);
ParamV.Add(BetaM);
ParamV.Add(GammaM);
ParamV.Add(BetaB);
ParamV.Add(GammaB);
ParamV.Add(BetaMB);
ParamV.Add(BetaBM);
}
示例8: GetSngVec
void GetSngVec(const PNGraph& Graph, const int& SngVecs, TFltV& SngValV, TVec<TFltV>& LeftSV, TVec<TFltV>& RightSV) {
const int Nodes = Graph->GetNodes();
SngValV.Clr();
LeftSV.Clr();
RightSV.Clr();
TFltVV LSingV, RSingV;
if (Nodes < 100) {
// perform full SVD
TFltVV AdjMtx(Nodes+1, Nodes+1);
TIntH NodeIdH;
// create adjecency matrix (1-based)
for (TNGraph::TNodeI NodeI = Graph->BegNI(); NodeI < Graph->EndNI(); NodeI++) {
NodeIdH.AddKey(NodeI.GetId()); }
for (TNGraph::TNodeI NodeI = Graph->BegNI(); NodeI < Graph->EndNI(); NodeI++) {
const int NodeId = NodeIdH.GetKeyId(NodeI.GetId())+1;
for (int e = 0; e < NodeI.GetOutDeg(); e++) {
const int DstNId = NodeIdH.GetKeyId(NodeI.GetOutNId(e))+1; // no self edges
if (NodeId != DstNId) AdjMtx.At(NodeId, DstNId) = 1;
}
}
try { // can fail to converge but results seem to be good
TSvd::Svd1Based(AdjMtx, LSingV, SngValV, RSingV);
} catch(...) {
printf("\n***No SVD convergence: G(%d, %d)\n", Nodes, Graph->GetEdges());
}
} else { // Lanczos
TNGraphMtx GraphMtx(Graph);
TSparseSVD::LanczosSVD(GraphMtx, SngVecs, 2*SngVecs, ssotFull, SngValV, LSingV, RSingV);
//TGAlg::SaveFullMtx(Graph, "adj_mtx.txt");
//TLAMisc::DumpTFltVVMjrSubMtrx(LSingV, LSingV.GetRows(), LSingV.GetCols(), "LSingV2.txt"); // save MTX
}
TFltIntPrV SngValIdV;
for (int i = 0; i < SngValV.Len(); i++) {
SngValIdV.Add(TFltIntPr(SngValV[i], i));
}
SngValIdV.Sort(false);
SngValV.Sort(false);
for (int v = 0; v < SngValIdV.Len(); v++) {
LeftSV.Add();
LSingV.GetCol(SngValIdV[v].Val2, LeftSV.Last());
RightSV.Add();
RSingV.GetCol(SngValIdV[v].Val2, RightSV.Last());
}
IsAllValVNeg(LeftSV[0], true);
IsAllValVNeg(RightSV[0], true);
}