本文整理汇总了C++中InitRandom函数的典型用法代码示例。如果您正苦于以下问题:C++ InitRandom函数的具体用法?C++ InitRandom怎么用?C++ InitRandom使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitRandom函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: InitRandom
void NeuronalNet::CreateNet() {
// init random weights:
InitRandom(&inputWeights, 71);
InitRandom(&hiddenBias, 25);
InitRandom(&hiddenWeights, 25);
InitRandom(&outputBias, 1);
}
开发者ID:fankib,项目名称:SurfAlarm,代码行数:10,代码来源:NeuronalNet.cpp
示例2: NextRandom
static void NextRandom(double *random, long n)
{
long j;
if (idum<=0) InitRandom(0.0);
while (n--) {
/* compute idum= (IA1*idum)%IM1 without overflow */
idum= IA1*(idum%IQ1) - IR1*(idum/IQ1);
if (idum<0) idum+= IM1;
/* compute idum2= (IA2*idum2)%IM2 without overflow */
idum2= IA2*(idum2%IQ2) - IR2*(idum2/IQ2);
if (idum2<0) idum2+= IM2;
/* previous result is used to determine which element of the shuffle
table to use for this result */
j= iy/NDIV; /* in range 0..NTAB-1 */
iy= iv[j]-idum2;
iv[j]= idum;
if (iy<1) iy+= IMM1;
/* Really only IMM1 possible values can be returned, 1<=iy<=IMM1.
Algorithm given by Press and Teukolsky has a slight bug.
Here, the return values are centered in IMM1 equal bins.
If 2.e9 distinct values are not enough, could use, say, idum2
to scoot the points around randomly within bins... */
*random++= AM*(iy-0.5);
}
}
开发者ID:MattWherry,项目名称:yorick,代码行数:29,代码来源:std1.c
示例3: main
int main( int argc, char **argv )
{
int num_sample=100000;
int t0=clock();
InitRandom(100000);
int t1=clock();
///Initialization performance
printf("** Time elapsed for initialization of %d sample is %d\n \n",num_sample,t1-t0);
Hash2D.Set(Allocated.begin(),Allocated.end());
///Box Query performance
t0=clock();
MyScalarType avg_test=TestBox(num_sample);
t1=clock();
printf("** Time elapsed for %d BOX queries is %d\n, average found %5.5f \n \n",num_sample,t1-t0,avg_test);
///Intersecting segment performance
t0=clock();
MyScalarType avg_int=TestIntersection(num_sample);
t1=clock();
printf("** Time elapsed for %d INTERSECTION queries is %d\n, average found %5.5f \n \n",num_sample,t1-t0,avg_int);
///closest test
t0=clock();
MyScalarType avg_clos=TestClosest(num_sample);
t1=clock();
printf("** Time elapsed for %d CLOSEST queries is %d\n, average found %5.5f \n \n",num_sample,t1-t0,avg_clos);
///reinitialize structure
MyMark.mark=0;
Hash2D.Clear();
int n_test=1000;
InitRandom(n_test,100,0.1);
Hash2D.Set(Allocated.begin(),Allocated.end());
int tested_int=TestCorrectIntersect(n_test);
printf("** Correct Intersect on %d test are %d \n",n_test,tested_int);
int tested_clos=TestCorrectClosest(n_test);
printf("** Correct Closest on %d test are %d \n",n_test,tested_clos);
return 0;
}
开发者ID:HaiJiaoXinHeng,项目名称:meshlab,代码行数:45,代码来源:test_hash2D.cpp
示例4: Y_random_seed
void Y_random_seed(int nArgs)
{
double seed= 0.0;
if (nArgs==1) {
if (YNotNil(sp)) seed= YGetReal(sp);
} else if (nArgs>0) {
YError("random_seed takes exactly zero or one arguments");
}
InitRandom(seed);
}
开发者ID:MattWherry,项目名称:yorick,代码行数:10,代码来源:std1.c
示例5: InitBackground
void InitBackground()
{
int x, y;
InitRandom();
for ( x = 0; x < PARALLAX_GRID_WIDTH; x++ ) {
for ( y = 0; y < PARALLAX_GRID_HEIGHT; y++ ) {
front_tiles[ x ][ y ] = GetRandom() % num_star_tiles;
back_tiles[ x ][ y ] = GetRandom() % num_star_tiles;
}
}
}
开发者ID:jimijimi,项目名称:SDL2_PLG,代码行数:12,代码来源:background.c
示例6: METIS_WPartGraphRecursive
/*************************************************************************
* This function is the entry point for PWMETIS that accepts exact weights
* for the target partitions
**************************************************************************/
void METIS_WPartGraphRecursive(int *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts,
floattype *tpwgts, int *options, int *edgecut, idxtype *part)
{
int i, j;
GraphType graph;
CtrlType ctrl;
floattype *mytpwgts;
if (*numflag == 1)
Change2CNumbering(*nvtxs, xadj, adjncy);
SetUpGraph(&graph, OP_PMETIS, *nvtxs, 1, xadj, adjncy, vwgt, adjwgt, *wgtflag);
if (options[0] == 0) { /* Use the default parameters */
ctrl.CType = PMETIS_CTYPE;
ctrl.IType = PMETIS_ITYPE;
ctrl.RType = PMETIS_RTYPE;
ctrl.dbglvl = PMETIS_DBGLVL;
}
else {
ctrl.CType = options[OPTION_CTYPE];
ctrl.IType = options[OPTION_ITYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
}
ctrl.optype = OP_PMETIS;
ctrl.CoarsenTo = 20;
ctrl.maxvwgt = 1.5*(idxsum(*nvtxs, graph.vwgt)/ctrl.CoarsenTo);
mytpwgts = fmalloc(*nparts, "PWMETIS: mytpwgts");
for (i=0; i<*nparts; i++)
mytpwgts[i] = tpwgts[i];
InitRandom(-1);
AllocateWorkSpace(&ctrl, &graph, *nparts);
IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl));
IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr));
*edgecut = MlevelRecursiveBisection(&ctrl, &graph, *nparts, part, mytpwgts, 1.000, 0);
IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr));
IFSET(ctrl.dbglvl, DBG_TIME, PrintTimers(&ctrl));
FreeWorkSpace(&ctrl, &graph);
free(mytpwgts);
if (*numflag == 1)
Change2FNumbering(*nvtxs, xadj, adjncy, part);
}
开发者ID:davidheryanto,项目名称:sc14,代码行数:56,代码来源:pmetis.c
示例7: METIS_EdgeND
/*************************************************************************
* This function is the entry point for OEMETIS
**************************************************************************/
void METIS_EdgeND(int *nvtxs, idxtype *xadj, idxtype *adjncy, int *numflag, int *options,
idxtype *perm, idxtype *iperm)
{
int i, j;
GraphType graph;
CtrlType ctrl;
if (*numflag == 1)
Change2CNumbering(*nvtxs, xadj, adjncy);
SetUpGraph(&graph, OP_OEMETIS, *nvtxs, 1, xadj, adjncy, NULL, NULL, 0);
if (options[0] == 0) { /* Use the default parameters */
ctrl.CType = OEMETIS_CTYPE;
ctrl.IType = OEMETIS_ITYPE;
ctrl.RType = OEMETIS_RTYPE;
ctrl.dbglvl = OEMETIS_DBGLVL;
}
else {
ctrl.CType = options[OPTION_CTYPE];
ctrl.IType = options[OPTION_ITYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
}
ctrl.oflags = 0;
ctrl.pfactor = -1;
ctrl.nseps = 1;
ctrl.optype = OP_OEMETIS;
ctrl.CoarsenTo = 20;
ctrl.maxvwgt = 1.5*(idxsum(*nvtxs, graph.vwgt)/ctrl.CoarsenTo);
InitRandom(-1);
AllocateWorkSpace(&ctrl, &graph, 2);
IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl));
IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr));
MlevelNestedDissection(&ctrl, &graph, iperm, ORDER_UNBALANCE_FRACTION, *nvtxs);
IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr));
IFSET(ctrl.dbglvl, DBG_TIME, PrintTimers(&ctrl));
for (i=0; i<*nvtxs; i++)
perm[iperm[i]] = i;
FreeWorkSpace(&ctrl, &graph);
if (*numflag == 1)
Change2FNumberingOrder(*nvtxs, xadj, adjncy, perm, iperm);
}
开发者ID:iyer-arvind,项目名称:gmsh,代码行数:55,代码来源:ometis.c
示例8: m_vNum
SRBM::SRBM(int vNum, int hNum):
m_vNum(vNum), m_hNum(hNum)
{
// allocate space
m_pVB = (double *) m_pool.Allocate(sizeof(double) * vNum);
m_pHB = (double *) m_pool.Allocate(sizeof(double) * hNum);
m_ppW = (double **)m_pool.Allocate(sizeof(double*) * vNum);
for (int i = 0; i < vNum; ++i)
m_ppW[i] = (double *) m_pool.Allocate(sizeof(double) * hNum);
// randomly initialize
InitRandom();
}
开发者ID:majineu,项目名称:WRRBM,代码行数:13,代码来源:RBM.cpp
示例9: METIS_NodeComputeSeparator
/*************************************************************************
* This function is the entry point for ONWMETIS. It requires weights on the
* vertices. It is for the case that the matrix has been pre-compressed.
**************************************************************************/
void METIS_NodeComputeSeparator(int *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
idxtype *adjwgt, float *ubfactor, int *options, int *sepsize, idxtype *part)
{
int i, j, tvwgt, tpwgts[2];
GraphType graph;
CtrlType ctrl;
SetUpGraph(&graph, OP_ONMETIS, *nvtxs, 1, xadj, adjncy, vwgt, adjwgt, 3);
tvwgt = idxsum(*nvtxs, graph.vwgt);
if (options[0] == 0) { /* Use the default parameters */
ctrl.CType = ONMETIS_CTYPE;
ctrl.IType = ONMETIS_ITYPE;
ctrl.RType = ONMETIS_RTYPE;
ctrl.dbglvl = ONMETIS_DBGLVL;
}
else {
ctrl.CType = options[OPTION_CTYPE];
ctrl.IType = options[OPTION_ITYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
}
ctrl.oflags = OFLAG_COMPRESS; /* For by-passing the pre-coarsening for multiple runs */
ctrl.RType = 2; /* Standard 1-sided node refinement code */
ctrl.pfactor = 0;
ctrl.nseps = 5; /* This should match NUM_INIT_MSECTIONS in ParMETISLib/defs.h */
ctrl.optype = OP_ONMETIS;
InitRandom(options[7]);
AllocateWorkSpace(&ctrl, &graph, 2);
/*============================================================
* Perform the bisection
*============================================================*/
tpwgts[0] = tvwgt/2;
tpwgts[1] = tvwgt-tpwgts[0];
MlevelNodeBisectionMultiple(&ctrl, &graph, tpwgts, *ubfactor*.95);
*sepsize = graph.pwgts[2];
idxcopy(*nvtxs, graph.where, part);
GKfree((void **)&graph.gdata, &graph.rdata, &graph.label, LTERM);
FreeWorkSpace(&ctrl, &graph);
}
开发者ID:rondiplomatico,项目名称:parmetis3.2,代码行数:54,代码来源:parmetis.c
示例10: METIS_NodeComputeSeparator
/*************************************************************************
* This function is the entry point for ONWMETIS. It requires weights on the
* vertices. It is for the case that the matrix has been pre-compressed.
**************************************************************************/
void METIS_NodeComputeSeparator(idxtype *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
idxtype *adjwgt, idxtype *options, idxtype *sepsize, idxtype *part)
{
idxtype i, j, tvwgt, tpwgts[2];
GraphType graph;
CtrlType ctrl;
SetUpGraph(&graph, OP_ONMETIS, *nvtxs, 1, xadj, adjncy, vwgt, adjwgt, 3);
tvwgt = idxsum(*nvtxs, graph.vwgt, 1);
if (options[0] == 0) { /* Use the default parameters */
ctrl.CType = ONMETIS_CTYPE;
ctrl.IType = ONMETIS_ITYPE;
ctrl.RType = ONMETIS_RTYPE;
ctrl.dbglvl = ONMETIS_DBGLVL;
}
else {
ctrl.CType = options[OPTION_CTYPE];
ctrl.IType = options[OPTION_ITYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
}
ctrl.oflags = 0;
ctrl.pfactor = 0;
ctrl.nseps = 3;
ctrl.optype = OP_ONMETIS;
ctrl.CoarsenTo = amin(100, *nvtxs-1);
ctrl.maxvwgt = 1.5*tvwgt/ctrl.CoarsenTo;
InitRandom(options[7]);
AllocateWorkSpace(&ctrl, &graph, 2);
/*============================================================
* Perform the bisection
*============================================================*/
tpwgts[0] = tvwgt/2;
tpwgts[1] = tvwgt-tpwgts[0];
MlevelNodeBisectionMultiple(&ctrl, &graph, tpwgts, 1.02);
*sepsize = graph.pwgts[2];
idxcopy(*nvtxs, graph.where, part);
FreeGraph(&graph, 0);
FreeWorkSpace(&ctrl, &graph);
}
开发者ID:educharlie,项目名称:HNA-Algorithm,代码行数:54,代码来源:parmetis.c
示例11: METIS_mCPartGraphKway
/*************************************************************************
* This function is the entry point for KWMETIS
**************************************************************************/
void METIS_mCPartGraphKway(int *nvtxs, int *ncon, idxtype *xadj, idxtype *adjncy,
idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag,
int *nparts, floattype *rubvec, int *options, int *edgecut,
idxtype *part)
{
int i, j;
GraphType graph;
CtrlType ctrl;
if (*numflag == 1)
Change2CNumbering(*nvtxs, xadj, adjncy);
SetUpGraph(&graph, OP_KMETIS, *nvtxs, *ncon, xadj, adjncy, vwgt, adjwgt, *wgtflag);
if (options[0] == 0) { /* Use the default parameters */
ctrl.CType = McKMETIS_CTYPE;
ctrl.IType = McKMETIS_ITYPE;
ctrl.RType = McKMETIS_RTYPE;
ctrl.dbglvl = McKMETIS_DBGLVL;
}
else {
ctrl.CType = options[OPTION_CTYPE];
ctrl.IType = options[OPTION_ITYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
}
ctrl.optype = OP_KMETIS;
ctrl.CoarsenTo = amax((*nvtxs)/(20*log2Int(*nparts)), 30*(*nparts));
ctrl.nmaxvwgt = 1.5/(1.0*ctrl.CoarsenTo);
InitRandom(-1);
AllocateWorkSpace(&ctrl, &graph, *nparts);
IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl));
IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr));
ASSERT(CheckGraph(&graph));
*edgecut = MCMlevelKWayPartitioning(&ctrl, &graph, *nparts, part, rubvec);
IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr));
IFSET(ctrl.dbglvl, DBG_TIME, PrintTimers(&ctrl));
FreeWorkSpace(&ctrl, &graph);
if (*numflag == 1)
Change2FNumbering(*nvtxs, xadj, adjncy, part);
}
开发者ID:davidheryanto,项目名称:sc14,代码行数:52,代码来源:mkmetis.c
示例12: METIS_WPartGraphKway2
/*************************************************************************
* This function is the entry point for KWMETIS with seed specification
* in options[7]
**************************************************************************/
void METIS_WPartGraphKway2(idxtype *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
idxtype *adjwgt, idxtype *wgtflag, idxtype *numflag, idxtype *nparts,
float *tpwgts, idxtype *options, idxtype *edgecut, idxtype *part)
{
idxtype i, j;
GraphType graph;
CtrlType ctrl;
if (*numflag == 1)
Change2CNumbering(*nvtxs, xadj, adjncy);
SetUpGraph(&graph, OP_KMETIS, *nvtxs, 1, xadj, adjncy, vwgt, adjwgt, *wgtflag);
if (options[0] == 0) { /* Use the default parameters */
ctrl.CType = KMETIS_CTYPE;
ctrl.IType = KMETIS_ITYPE;
ctrl.RType = KMETIS_RTYPE;
ctrl.dbglvl = KMETIS_DBGLVL;
}
else {
ctrl.CType = options[OPTION_CTYPE];
ctrl.IType = options[OPTION_ITYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
}
ctrl.optype = OP_KMETIS;
ctrl.CoarsenTo = 20*(*nparts);
ctrl.maxvwgt = 1.5*((graph.vwgt ? idxsum(*nvtxs, graph.vwgt, 1) : (*nvtxs))/ctrl.CoarsenTo);
InitRandom(options[7]);
AllocateWorkSpace(&ctrl, &graph, *nparts);
IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl));
IFSET(ctrl.dbglvl, DBG_TIME, gk_startcputimer(ctrl.TotalTmr));
*edgecut = MlevelKWayPartitioning(&ctrl, &graph, *nparts, part, tpwgts, 1.03);
IFSET(ctrl.dbglvl, DBG_TIME, gk_stopcputimer(ctrl.TotalTmr));
IFSET(ctrl.dbglvl, DBG_TIME, PrintTimers(&ctrl));
FreeWorkSpace(&ctrl, &graph);
if (*numflag == 1)
Change2FNumbering(*nvtxs, xadj, adjncy, part);
}
开发者ID:educharlie,项目名称:HNA-Algorithm,代码行数:50,代码来源:parmetis.c
示例13: LearnableParameter
LearnableParameter<ElemType>::LearnableParameter(const ScriptableObjects::IConfigRecordPtr configp) :
LearnableParameter(configp->Get(L"deviceId"), L"<placeholder>", configp->Get(L"shape"))
{
// TODO: Change dimensions to take a generic tensor instead. That will be a (minor) breaking change that will require fix-ups when converting from NDL to BrainScript.
AttachInputsFromConfig(configp, this->GetExpectedNumInputs());
// parameters[rows, [cols=1]] plus other optional parameters (learningRateMultiplier=[1|0|float], init=[uniform|gaussian|fixedvalue], initValueScale=[1|float], value=[0|float])
if (configp->Exists(L"learningRateMultiplier"))
SetLearningRateMultiplier(configp->Get(L"learningRateMultiplier"));
else if (configp->Exists(L"needsGradient") || configp->Exists(L"needGradient") || configp->Exists(L"computeGradient"))
InvalidArgument("Deprecated parameter names needsGradient|needGradient|computeGradient are not supported in BrainScript. Use learningRateMultiplier instead.");
wstring initString = configp->Get(L"init");
if (initString == L"fixedValue")
Value().SetValue((ElemType) configp->Get(L"value"));
else if (initString == L"uniform" || initString == L"gaussian")
{
// TODO: add these options also to old NDL
static unsigned long randomSeed = 1;
int forcedRandomSeed = configp->Get(L"randomSeed"); // forcing a specific random seed is useful for testing to get repeatable initialization independent of evaluation order
InitRandom((initString == L"uniform"), forcedRandomSeed < 0 ? randomSeed++ : (unsigned long) forcedRandomSeed, configp->Get(L"initValueScale"), configp->Get(L"initOnCPUOnly"));
}
else if (initString == L"fromFile")
{
wstring initFromFilePath = configp->Get(L"initFromFilePath");
if (initFromFilePath.empty())
RuntimeError("initFromFilePath parameter must be provided when using \"fromFile\" initialization method");
InitFromFile(initFromFilePath);
}
else if (initString == L"fromLiteral")
{
wstring initFromLiteral = configp->Get(L"initFromLiteral");
if (initFromLiteral.empty())
RuntimeError("initFromLiteral parameter must be provided when using \"fromLiteral\" initialization method");
size_t numRows, numCols;
auto array = File::LoadMatrixFromStringLiteral<ElemType>(msra::strfun::utf8(initFromLiteral), numRows, numCols);
InitFromArray(array, numRows, numCols);
}
else
RuntimeError("init must be one of the values of [ uniform | gaussian | fixedValue | fromFile ]");
}
开发者ID:ShuaiW,项目名称:CNTK,代码行数:40,代码来源:InputAndParamNodes.cpp
示例14: main
int main(int argc, char *argv[])
{
#if HAVE_SETBUF
setbuf(stdin, NULL);
#endif
OpenLogFile("Amy.log");
InitMoves();
InitAll();
HashInit();
/*
* Process rc file first, then command line options. This way command
* line options can override rc file settings.
*/
ProcessRCFile();
ProcessOptions(argc, argv);
ShowVersion();
AllocateHT();
InitEGTB(EGTBPath);
RecogInit();
DoBookLearning();
Print(0, "\n");
strcpy(AutoSaveFileName, GetTmpFileName());
/* Ensure true random behavior. */
InitRandom(GetTime());
StateMachine();
return 0;
}
开发者ID:thgreiner,项目名称:amy,代码行数:40,代码来源:main.c
示例15: InitNumBit16Table
void Util::InitUtil() {
// num_bit16_table_[]を初期化する。
InitNumBit16Table();
// attack_table_***_[][]を初期化する。
InitAttackTable();
// pawn_move_[][]を初期化する。
InitPawnMove();
// pawn_2step_move_[][]を初期化する。
InitPawn2StepMove();
// pawn_attack_[][]を初期化する。
InitPawnAttack();
// knight_move_[]を初期化する。
InitKnightMove();
// bishop_move_[]を初期化する。
InitBishopMove();
// rook_move_[]を初期化する。
InitRookMove();
// king_move_[]を初期化する。
InitKingMove();
// ランダム関連を初期化する。
InitRandom();
}
开发者ID:phenri,项目名称:sayuri,代码行数:22,代码来源:chess_util.cpp
示例16: METIS_EstimateMemory
/*************************************************************************
* This function computes how much memory will be required by the various
* routines in METIS
**************************************************************************/
void METIS_EstimateMemory(int *nvtxs, idxtype *xadj, idxtype *adjncy, int *numflag, int *optype, int *nbytes)
{
int i, j, k, nedges, nlevels;
floattype vfraction, efraction, vmult, emult;
int coresize, gdata, rdata;
if (*numflag == 1)
Change2CNumbering(*nvtxs, xadj, adjncy);
nedges = xadj[*nvtxs];
InitRandom(-1);
EstimateCFraction(*nvtxs, xadj, adjncy, &vfraction, &efraction);
/* Estimate the amount of memory for coresize */
if (*optype == 2)
coresize = nedges;
else
coresize = 0;
coresize += nedges + 11*(*nvtxs) + 4*1024 + 2*(NEG_GAINSPAN+PLUS_GAINSPAN+1)*(sizeof(ListNodeType *)/sizeof(idxtype));
coresize += 2*(*nvtxs); /* add some more fore other vectors */
gdata = nedges; /* Assume that the user does not pass weights */
nlevels = (int)(log(100.0/(*nvtxs))/log(vfraction) + .5);
vmult = 0.5 + (1.0 - pow(vfraction, nlevels))/(1.0 - vfraction);
emult = 1.0 + (1.0 - pow(efraction, nlevels+1))/(1.0 - efraction);
gdata += vmult*4*(*nvtxs) + emult*2*nedges;
if ((vmult-1.0)*4*(*nvtxs) + (emult-1.0)*2*nedges < 5*(*nvtxs))
rdata = 0;
else
rdata = 5*(*nvtxs);
*nbytes = sizeof(idxtype)*(coresize+gdata+rdata+(*nvtxs));
if (*numflag == 1)
Change2FNumbering2(*nvtxs, xadj, adjncy);
}
开发者ID:davidheryanto,项目名称:sc14,代码行数:43,代码来源:estmem.c
示例17: main
int main( int argc, char **argv )
{
(void) argc;
(void) argv;
int num_sample=20000;
int t0=clock();
printf("** Random Initialization ** \n");
fflush(stdout);
InitRandom(num_sample,100,0.3);
int t1=clock();
///Initialization performance
printf("** Time elapsed for initialization of %d sample is %d\n \n",num_sample,t1-t0);
Grid2D.Set(AllocatedSeg.begin(),AllocatedSeg.end());
fflush(stdout);
//Box Query correctness
TestBox(num_sample);
TestClosest(num_sample);
TestRay(num_sample);
return 0;
}
开发者ID:ezhangle,项目名称:vcglib-1,代码行数:24,代码来源:test_hash2D.cpp
示例18: main
int main(int argc, char *argv[])
{
int i, npart;
idxtype *part;
float ncut=0;
GraphType graph;
char filename[256],outputFile[256];
int wgtflag = 0, addSelfLoop=1, outputFileGiven=0, txtFormat=0 ;
int randomInit = 0;
idxtype minEdgeWeight = 0;
Options opt;
timer TOTALTmr, METISTmr, IOTmr;
initOptions(&opt);
if (argc < 2) {
print_help(argv[0]);
exit(0);
}
for (argv++; *argv != NULL; argv++){
if ((*argv)[0] == '-')
{
int temp;
switch ((*argv)[1])
{
case 'b':
case 'B':
opt.penalty_power=atof(*(++argv));
break;
case 'i':
case 'I':
opt.gamma=atof(*(++argv));
break;
case 'o':
case 'O':
strcpy(outputFile,*(++argv));
outputFileGiven=1;
break;
case 'D'://quality threshold. This is a post-processing step proposed in SR-MCL. If you dont want post-processing (this is what original MLR-MCL, R-MCL, MCL do, please set "-d 0"
case 'd':
opt.quality_threshold = atof(*(++argv));
break;
case 'w':
case 'W':
opt.weighted_density = true;
break;
case 'c':
case 'C':
opt.coarsenTo= atoi(*(++argv));
break;
default:
printf("Invalid option %s\n", *argv);
print_help(argv[0]);
exit(0);
}
}
else
{
strcpy(filename, *argv);
}
}
if ( randomInit > 0 )
InitRandom(time(NULL));
else
InitRandom(-1);
cleartimer(TOTALTmr);
cleartimer(METISTmr);
cleartimer(IOTmr);
starttimer(TOTALTmr);
starttimer(IOTmr);
ReadGraph(&graph, filename, &wgtflag, addSelfLoop, txtFormat);
if ( opt.matchType == MATCH_UNSPECIFIED )
{
// opt.matchType = (graph.nvtxs>50000) ? MATCH_POWERLAW_FC :
// MATCH_SHEMN;
opt.matchType = MATCH_SHEMN;
}
stoptimer(IOTmr);
if (graph.nvtxs <= 0) {
printf("Empty graph. Nothing to do.\n");
exit(0);
}
int noOfSingletons = 0;
GraphType *noSingletonGraph ;
idxtype* nodeMap = lookForSingletons(&graph, &noOfSingletons);
if ( noOfSingletons > 0 )
{
getSubgraph(&graph, nodeMap, graph.nvtxs-noOfSingletons,
wgtflag, &noSingletonGraph);
GKfree((void**)&(graph.xadj), (void**)&(graph.adjncy), LTERM);
//.........这里部分代码省略.........
开发者ID:koadman,项目名称:proxigenomics,代码行数:101,代码来源:mlrmcl.c
示例19: time
void hack::Initialize()
{
::signal(SIGSEGV, &critical_error_handler);
::signal(SIGABRT, &critical_error_handler);
time_injected = time(nullptr);
/*passwd *pwd = getpwuid(getuid());
char *logname = strfmt("/tmp/cathook-game-stdout-%s-%u.log", pwd->pw_name,
time_injected);
freopen(logname, "w", stdout);
free(logname);
logname = strfmt("/tmp/cathook-game-stderr-%s-%u.log", pwd->pw_name,
time_injected);
freopen(logname, "w", stderr);
free(logname);*/
// Essential files must always exist, except when the game is running in text
// mode.
#if ENABLE_VISUALS
{
std::vector<std::string> essential = { "fonts/tf2build.ttf" };
for (const auto &s : essential)
{
std::ifstream exists(DATA_PATH "/" + s, std::ios::in);
if (not exists)
{
Error(("Missing essential file: " + s +
"/%s\nYou MUST run install-data script to finish "
"installation")
.c_str(),
s.c_str());
}
}
}
#endif /* TEXTMODE */
logging::Info("Initializing...");
InitRandom();
sharedobj::LoadAllSharedObjects();
CreateInterfaces();
CDumper dumper;
dumper.SaveDump();
logging::Info("Is TF2? %d", IsTF2());
logging::Info("Is TF2C? %d", IsTF2C());
logging::Info("Is HL2DM? %d", IsHL2DM());
logging::Info("Is CSS? %d", IsCSS());
logging::Info("Is TF? %d", IsTF());
InitClassTable();
BeginConVars();
g_Settings.Init();
EndConVars();
#if ENABLE_VISUALS
draw::Initialize();
#if ENABLE_GUI
// FIXME put gui here
#endif
#endif /* TEXTMODE */
gNetvars.init();
InitNetVars();
g_pLocalPlayer = new LocalPlayer();
g_pPlayerResource = new TFPlayerResource();
uintptr_t *clientMode = 0;
// Bad way to get clientmode.
// FIXME [MP]?
while (!(clientMode = **(uintptr_t ***) ((uintptr_t)((*(void ***) g_IBaseClient)[10]) + 1)))
{
usleep(10000);
}
hooks::clientmode.Set((void *) clientMode);
hooks::clientmode.HookMethod(HOOK_ARGS(CreateMove));
#if ENABLE_VISUALS
hooks::clientmode.HookMethod(HOOK_ARGS(OverrideView));
#endif
hooks::clientmode.HookMethod(HOOK_ARGS(LevelInit));
hooks::clientmode.HookMethod(HOOK_ARGS(LevelShutdown));
hooks::clientmode.Apply();
hooks::clientmode4.Set((void *) (clientMode), 4);
hooks::clientmode4.HookMethod(HOOK_ARGS(FireGameEvent));
hooks::clientmode4.Apply();
hooks::client.Set(g_IBaseClient);
hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage));
#if ENABLE_VISUALS
hooks::client.HookMethod(HOOK_ARGS(FrameStageNotify));
hooks::client.HookMethod(HOOK_ARGS(IN_KeyEvent));
#endif
hooks::client.Apply();
#if ENABLE_VISUALS
hooks::vstd.Set((void *) g_pUniformStream);
hooks::vstd.HookMethod(HOOK_ARGS(RandomInt));
hooks::vstd.Apply();
hooks::panel.Set(g_IPanel);
hooks::panel.HookMethod(hooked_methods::methods::PaintTraverse, offsets::PaintTraverse(), &hooked_methods::original::PaintTraverse);
//.........这里部分代码省略.........
开发者ID:UNKN-0WN,项目名称:cathook,代码行数:101,代码来源:hack.cpp
示例20: main
int main(int argc, char **argv)
{
CUNICODE_STRING us;
THREAD *initial_thread = NULL;
const char *exename;
ParseOptions( argc, argv );
if (optind == argc)
{
// default to starting smss.exe
exename = "\\??\\c:\\winnt\\system32\\smss.exe";
}
else
{
exename = argv[optind];
}
// Read debug channels options
DebugInit();
// the skas3 patch is deprecated...
if (0) InitSkas();
// pass our path so thread tracing can find the client stub
InitTt( argv[0] );
if (!pCreateAddressSpace)
Die("no way to manage address spaces found\n");
if (!TraceIsEnabled("core"))
{
// enable backtraces
signal(SIGSEGV, SegvHandler);
signal(SIGABRT, AbortHandler);
}
if (RegistryIndex >= 0)
{
TRACE("created registry: %s\n",registry_list[RegistryIndex].name);
Registry = registry_list[RegistryIndex].create();
}
else
{
TRACE("created registry: xml\n");
Registry = REGISTRY_XML::Create();
}
// quick sanity test
ALLOCATION_BITMAP::Test();
// initialize boottime
SYSTEM_TIME_OF_DAY_INFORMATION dummy;
GetSystemTimeOfDay( dummy );
FIBER::FibersInit();
InitRoot();
CreateDirectoryObject( (PWSTR) L"\\" );
CreateDirectoryObject( (PWSTR) L"\\??" );
CUNICODE_STRING link_name, link_target;
link_name.Set( L"\\DosDevices" );
link_target.Copy( L"\\??" );
CreateSymlink( link_name, link_target );
CreateDirectoryObject( (PWSTR) L"\\Device" );
CreateDirectoryObject( (PWSTR) L"\\Device\\MailSlot" );
CreateDirectoryObject( (PWSTR) L"\\Security" );
//create_directory_object( (PWSTR) L"\\DosDevices" );
CreateDirectoryObject( (PWSTR) L"\\BaseNamedObjects" );
CreateSyncEvent( (PWSTR) L"\\Security\\LSA_AUTHENTICATION_INITIALIZED" );
CreateSyncEvent( (PWSTR) L"\\SeLsaInitEvent" );
InitRandom();
InitPipeDevice();
// XP
CreateDirectoryObject( (PWSTR) L"\\KernelObjects" );
CreateSyncEvent( (PWSTR) L"\\KernelObjects\\CritSecOutOfMemoryEvent" );
InitDrives();
InitNtDLL();
CreateKThread();
us.Copy( exename );
int r = CreateInitialProcess( &initial_thread, us );
if (r < STATUS_SUCCESS)
Die("create_initial_process() failed (%08x)\n", r);
// run the main loop
Schedule();
NtGdiFini();
r = initial_thread->Process->ExitStatus;
//fprintf(stderr, "process exited (%08x)\n", r);
Release( initial_thread );
ShutdownKThread();
DoCleanup();
FreeRoot();
FIBER::FibersFinish();
FreeNtDLL();
//.........这里部分代码省略.........
开发者ID:bragin,项目名称:ring3k,代码行数:101,代码来源:main.cpp
注:本文中的InitRandom函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论