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


C++ sim函数代码示例

本文整理汇总了C++中sim函数的典型用法代码示例。如果您正苦于以下问题:C++ sim函数的具体用法?C++ sim怎么用?C++ sim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: sim

void
timbre::add_tracks(
        musly_track** tracks,
        musly_trackid* trackids,
        int length,
        bool generate_ids) {
    int num_new;
    if (generate_ids) {
        idpool.generate_ids(trackids, length);
        num_new = length;
    }
    else {
        num_new = idpool.add_ids(trackids, length);
    }

    Eigen::VectorXf sim(mp.get_normtracks()->size());
    mp.append_normfacts(num_new);
    int pos = idpool.get_size() - length;
    for (int i = 0; i < length; i++) {
        similarity_raw(tracks[i], mp.get_normtracks()->data(),
                mp.get_normtracks()->size(), sim.data());

        mp.set_normfacts(pos + i, sim);
    }
}
开发者ID:agangzz,项目名称:musly,代码行数:25,代码来源:timbre.cpp

示例2: main

int main (int argc, char* argv[]) {
	// Initialize options
	int i;
	get_ops(NULL);
	for (i=1; i<argc; ++i) {
		get_ops(argv[i]);
	}

	// Seed RNG
	if (ops.seedFlag) {
		srand(ops.seed);
	} else {
		srand(time(NULL));
	}

	// Read in nuclei
	if (get_nuclei(ops.nuclei_filename)==false) {
		exit(EXIT_FAILURE);
	}

	// Read in reactions
	if (get_reactions(ops.reaclib_filename)==false) {
		exit(EXIT_FAILURE);
	}

	sim();

	free(nuclei);
	free(abun);
	free(reactions);
	return 0;
}
开发者ID:j-browne,项目名称:reacnet,代码行数:32,代码来源:reacnet.c

示例3: main

int main(int argc, char **argv)
{
    PseudoRandomSeed();
  
    dInitODE();

//create simulator and set robot position at (0, -8)  
    Simulator sim(0, -8);    

//create motion planner
    MotionPlanner mp(&sim);    

//create graphics
    Graphics graphics(&mp);
    
//create obstacles and terrain
    CreateWorld1(&sim);
    
//if argument specified, set as maximum motion planning time
    if(argc > 1)
	graphics.SetMotionPlannerMaxTime(atof(argv[1]));    

//print help messages
    graphics.HandleEventOnHelp();

//enter event loop
    graphics.MainLoop();
    
    return 0;    
}
开发者ID:basson86,项目名称:ASBR-CPP-2010,代码行数:30,代码来源:Main.cpp

示例4: main

int main(void)
{
	Rossler<double> ross(0.398,2.0,4.0);
	RungeKutta4<double> integrator(1e-2);
//	Euler<double> integrator(1e-2);
	Simulation<double> sim(ross,integrator);

	double ti = 0.0;
	double tf = 200.0;
	long npts = 10000;

	std::ofstream datfile("out.dat", std::ios::out | std::ios::trunc);

	ross.x(0) = 0.0;
	ross.x(1) = 0.0;
	ross.x(2) = 0.0;

	if (datfile)
	{
		//sim.run(std::cout, ti, tf);
		//sim.run(datfile, npts);
		sim.run(datfile, ti, tf);
		
		datfile.close();
	}
	else
	{
		std::cerr << "Erreur à l'ouverture du fichier !" << std::endl;
	}
	
	return 0;

}
开发者ID:Aewos,项目名称:SysSim,代码行数:33,代码来源:Rossler.cpp

示例5: TEST

TEST(TestASMu3D, TransferGaussPtVars)
{
  SIM3D sim(1);
  sim.opt.discretization = ASM::LRSpline;
  sim.createDefaultModel();
  ASMu3D* pch = static_cast<ASMu3D*>(sim.getPatch(1));
  size_t id[3];
  const double* xi = GaussQuadrature::getCoord(3);
  RealArray oldAr(3*3*3), newAr;
  for (size_t idx = 0; idx < 3; ++idx) {
    SIM3D simNew(1);
    simNew.opt.discretization = ASM::LRSpline;
    simNew.createDefaultModel();
    ASMu3D* pchNew = static_cast<ASMu3D*>(simNew.getPatch(1));
    pchNew->uniformRefine(idx, 1);

    for (id[2] = 0; id[2] < 3; ++id[2])
      for (id[1] = 0; id[1] < 3; ++id[1])
        for (id[0] = 0; id[0] < 3; ++id[0])
          oldAr[id[0]+(id[1]+id[2]*3)*3] = (1.0 + xi[id[idx]]) / 2.0;

    pchNew->transferGaussPtVars(pch->getVolume(), oldAr, newAr, 3);
    size_t k = 0;
    for (size_t iEl = 0; iEl < 2; ++iEl)
      for (id[2] = 0; id[2] < 3; ++id[2])
        for (id[1] = 0; id[1] < 3; ++id[1])
          for (id[0] = 0; id[0] < 3; ++id[0], ++k)
            EXPECT_FLOAT_EQ(newAr[k], 0.5*iEl + 0.5*(xi[id[idx]] + 1.0) / 2.0);
  }
}
开发者ID:kmokstad,项目名称:IFEM-2,代码行数:30,代码来源:TestASMu3D.C

示例6: TEST

TEST(TestInitialConditions, Parse)
{
  SIM2D sim({4}, false);
  EXPECT_TRUE(sim.read("src/SIM/Test/refdata/input.xinp"));

  // Recognize both comp and component attributes and correct priority
  // Boundary conditions
  for (int i = 1; i < 5; i++)
    ASSERT_FLOAT_EQ((float)i,(*sim.getSclFunc(i))(Vec3()));
  // Initial conditions
  ASSERT_TRUE(sim.getICs().begin() != sim.getICs().end());
  const std::vector<SIMdependency::ICInfo>& bar = sim.getICs().begin()->second;
  for (std::vector<SIMdependency::ICInfo>::const_iterator info = bar.begin();
       info != bar.end(); info++)
    switch (info->component) {
      case 1:
        ASSERT_EQ(info->function, "1");
        break;
      case 2:
        ASSERT_EQ(info->function, "2");
        break;
      case 3:
        ASSERT_EQ(info->function, "3");
        break;
      case 4:
        ASSERT_EQ(info->function, "4");
        break;
      default:
        ASSERT_TRUE(false);
      }
}
开发者ID:OPM,项目名称:IFEM,代码行数:31,代码来源:TestInitialConditions.C

示例7: TEST_P

TEST_P(TestASMu3D, BoundaryNodes)
{
  if (GetParam() == 0 || GetParam() > 6)
    return;

  SIM3D sim(1);
  sim.opt.discretization = ASM::LRSpline;
  ASSERT_TRUE(sim.read("src/ASM/LR/Test/refdata/boundary_nodes_3d.xinp"));
  ASSERT_TRUE(sim.createFEMmodel());

  std::stringstream str;
  str << "Face" << GetParam();
  int bcode = sim.getUniquePropertyCode(str.str(),0);
  std::vector<int> vec;
  sim.getBoundaryNodes(bcode,vec);
  ASSERT_EQ(vec.size(), 16U);
  auto it = vec.begin();
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 4; ++j)
      if (GetParam() == 1)
        EXPECT_EQ(*it++, 1+4*(4*i+j));
      else if (GetParam() == 2)
        EXPECT_EQ(*it++, 2+4*(4*i+j));
      else if (GetParam() == 3)
        EXPECT_EQ(*it++, 16*i+j+1);
      else if (GetParam() == 4)
        EXPECT_EQ(*it++, 5+16*i+j);
      else if (GetParam() == 5)
        EXPECT_EQ(*it++, 4*i+j+1);
      else if (GetParam() == 6)
        EXPECT_EQ(*it++, 17+4*i+j);
}
开发者ID:kmokstad,项目名称:IFEM-2,代码行数:32,代码来源:TestASMu3D.C

示例8: TEST

TEST(TestDomainDecomposition, Setup)
{
  SIM2D sim(1);
  sim.read("src/ASM/Test/refdata/DomainDecomposition_2D_1P.xinp");
  sim.preprocess();

  DomainDecomposition dd;
  // TODO: Remove after integration
  dd.setup(sim.getProcessAdm(), sim);
  const SAM* sam = sim.getSAM();

  ASSERT_EQ(dd.getMinEq(), 1);
  ASSERT_EQ(dd.getMaxEq(), sam->getNoEquations());
  ASSERT_EQ(dd.getMinNode(), 1);
  ASSERT_EQ(dd.getMaxNode(), sam->getNoNodes());
  ASSERT_EQ(dd.getMinDOF(), 1);
  ASSERT_EQ(dd.getMaxDOF(), sam->getNoDOFs());
  for (int i = 1; i <= sam->getNoEquations(); ++i)
    ASSERT_EQ(dd.getGlobalEq(i), i);
  ASSERT_EQ(dd.getGlobalEq(sam->getNoEquations()+1), 0);

  // disabled until integration in the SIM class is added
//  ASSERT_EQ(dd.getPatchOwner(1), 0);
//  ASSERT_EQ(dd.getPatchOwner(2), -1);

  ASSERT_TRUE(dd.getMLGEQ().empty());
  ASSERT_TRUE(dd.getMLGN().empty());
}
开发者ID:OPM,项目名称:IFEM,代码行数:28,代码来源:TestDomainDecomposition.C

示例9: main

int main(int argc,char *argv[]) {
    if(argc != 5) {
            printf("Wrong Number of Arguments\n");
            exit(0);
    }

    //double alpha1 = argv[1]-0.0;
    double alpha1, alpha2, beta1, beta2, gamma1, gamma2, phi1, phi2;
    alpha1 = alpha2 = atof( argv[1] );
    beta1 = 0.35;
    beta2 = atof( argv[2] );
    gamma1 = gamma2 = 1.0/5.0;
    phi1 = phi2 = atof( argv[4]);
    int intro_time;
    intro_time = atoi( argv[3] );

    int num_reps = 5;

    Network net = Network("gillespie toy", Network::Undirected);
    net.populate(10000);
    net.connect_all_nodes();
    Gillespie_TwoStrain_Network_Sim sim(&net, alpha1, alpha2, gamma1, gamma2, beta1, beta2, phi1, phi2, intro_time);
    for(int i =1; i <= num_reps; i++){
        cout << "Simulation number: " << i << endl;
        sim.reset();
        sim.rand_infect(5, 1);
        sim.run_simulation(10000.0);
    }
    return 0;
}
开发者ID:sjfox,项目名称:EpiFire,代码行数:30,代码来源:gillespie_network_two_strain.cpp

示例10: TEST

TEST(Simplifier, JumpConstFold) {
  BCMarker dummy = BCMarker::Dummy();
  IRUnit unit(test_context);
  Simplifier sim(unit);

  // Folding JmpZero and JmpNZero.
  {
    auto tester = [&] (SSATmp* val, Opcode op) {
      auto jmp = unit.gen(op, dummy, unit.defBlock(), val);
      return sim.simplify(jmp, false);
    };

    auto resultFalseZero  = tester(unit.cns(false),  JmpZero);
    auto resultFalseNZero = tester(unit.cns(false), JmpNZero);
    auto resultTrueZero   = tester(unit.cns(true),   JmpZero);
    auto resultTrueNZero  = tester(unit.cns(true),  JmpNZero);

    EXPECT_SINGLE_OP(resultFalseNZero, Nop);
    EXPECT_SINGLE_OP(resultTrueZero, Nop);

    EXPECT_SINGLE_OP(resultFalseZero, Jmp);
    EXPECT_SINGLE_OP(resultTrueNZero, Jmp);
  }

  // Folding query jumps.
  {
    auto jmpeqTaken = unit.gen(JmpEq, dummy, unit.cns(10), unit.cns(10));
    auto result = sim.simplify(jmpeqTaken, false);
    EXPECT_SINGLE_OP(result, Jmp);

    auto jmpeqNTaken = unit.gen(JmpEq, dummy, unit.cns(10), unit.cns(400));
    result = sim.simplify(jmpeqNTaken, false);
    EXPECT_SINGLE_OP(result, Nop);
  }
}
开发者ID:CodeKong,项目名称:hhvm,代码行数:35,代码来源:simplifier.cpp

示例11: flamePrepare

/**
 * @brief Add a new simulation instance
 * @param name unique internal name for this instance
 * @param lattice file name
 */
void flamePrepare(const char *name, const char *lattice)
{
    if(!name) return;
    try {
        Guard G(SimGlobal.lock);

        if(SimGlobal.sims.find(name)!=SimGlobal.sims.end())
            throw std::runtime_error("Sim name already in use");

        std::auto_ptr<Config> conf;
        {
            GLPSParser parser;
            conf.reset(parser.parse_file(lattice));
        }

        std::auto_ptr<Sim> sim(new Sim(name));

        sim->machine.reset(new Machine(*conf));

        SimGlobal.sims[name] = sim.get();

        sim.release();

    }catch(std::exception& e){
        fprintf(stderr, "Error: %s\n", e.what());
    }
}
开发者ID:frib-high-level-controls,项目名称:FLAME,代码行数:32,代码来源:flame.cpp

示例12: assert

void FpuStackAllocator::pop_always(LIR_Op* op, LIR_Opr opr) {
  assert(op->fpu_pop_count() == 0, "fpu_pop_count alredy set");
  assert(tos_offset(opr) == 0, "can only pop stack top");

  op->set_fpu_pop_count(1);
  sim()->pop();
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:7,代码来源:c1_LinearScan_x86.cpp

示例13: main

int main() {
    
    // Construct Network
    Network net("name", Network::Undirected);
    net.populate(10000);
    net.erdos_renyi(5);

    cout << "days_ahead" << "," << "transmissibility1" << "," << "transmissibility2" << "," << "strain1" << "," << "strain2" << endl;

    for (int days_ahead = 0; days_ahead < 20; days_ahead ++){
        for (double transmissibility1 = 0.2; transmissibility1 <=  0.5; transmissibility1 += 0.05){
            for (double transmissibility2 = 0.2; transmissibility2 <= 0.5; transmissibility2 += 0.05){
                int i = 0;
                while ( i < 100){
                    // Choose and run simulation
                    Two_Strain_Percolation_Sim sim(&net);
                    sim.set_transmissibility1(transmissibility1);
                    sim.set_transmissibility2(transmissibility2);
                    sim.rand_infect(5, 0);
                    sim.run_headstart_simulation(days_ahead, 5);

                    if(sim.epidemic_size1() > 50){
                        cout << days_ahead << "," << transmissibility1 << "," << transmissibility2 << "," << sim.epidemic_size1() << "," << sim.epidemic_size2() << endl; 
                        i++;
                    }
                    
                    sim.reset();
                }
            }
        }
    }

    return 0;
}
开发者ID:sjfox,项目名称:EpiFire,代码行数:34,代码来源:headstart_percolation.cpp

示例14: sim

Else::PhysicsSimulatorPtr
Else::PhysicsSimulatorFactory::create( void )
{
    PhysicsSimulatorPtr sim( new PhysicsSimulator() );
    sim->setTimeStep( myTimeStep );
    return sim;
}
开发者ID:allenscape,项目名称:locomotor,代码行数:7,代码来源:PhysicsSimulatorFactory.cpp

示例15: process_enable_simulator

void process_enable_simulator(LLMessageSystem *msg, void **user_data)
{
    // enable the appropriate circuit for this simulator and
    // add its values into the gSimulator structure
    U64		handle;
    U32		ip_u32;
    U16		port;

    msg->getU64Fast(_PREHASH_SimulatorInfo, _PREHASH_Handle, handle);
    msg->getIPAddrFast(_PREHASH_SimulatorInfo, _PREHASH_IP, ip_u32);
    msg->getIPPortFast(_PREHASH_SimulatorInfo, _PREHASH_Port, port);

    // which simulator should we modify?
    LLHost sim(ip_u32, port);

    // Viewer trusts the simulator.
    msg->enableCircuit(sim, TRUE);
    LLWorld::getInstance()->addRegion(handle, sim);

    // give the simulator a message it can use to get ip and port
    llinfos << "simulator_enable() Enabling " << sim << " with code " << msg->getOurCircuitCode() << llendl;
    msg->newMessageFast(_PREHASH_UseCircuitCode);
    msg->nextBlockFast(_PREHASH_CircuitCode);
    msg->addU32Fast(_PREHASH_Code, msg->getOurCircuitCode());
    msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
    msg->addUUIDFast(_PREHASH_ID, gAgent.getID());
    msg->sendReliable(sim);
}
开发者ID:EmeraldViewer,项目名称:EmeraldViewer,代码行数:28,代码来源:llworld.cpp


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