Example #1
0
    ADB PolymerPropsAd::polymerWaterVelocityRatio(const ADB& c) const
    {

        const int nc = c.size();
        V mc(nc);
        V dmc(nc);

        for (int i = 0; i < nc; ++i) {
            double m = 0;
            double dm = 0;
            polymer_props_.computeMcWithDer(c.value()(i), m, dm);

            mc(i) = m;
            dmc(i) = dm;
        }

        ADB::M dmc_diag(dmc.matrix().asDiagonal());
        const int num_blocks = c.numBlocks();
        std::vector<ADB::M> jacs(num_blocks);
        for (int block = 0; block < num_blocks; ++block) {
            jacs[block] = dmc_diag * c.derivative()[block];
        }

        return ADB::function(std::move(mc), std::move(jacs));
    }
Example #2
0
GeneralMatrix* GeneralMatrix::Transpose(TransposedMatrix* tm, MatrixType mt)
{
   GeneralMatrix* gm1;

   if (Compare(Type().t(),mt))
   {
      REPORT
      gm1 = mt.New(ncols,nrows,tm);
      for (int i=0; i<ncols; i++)
      {
         MatrixRow mr(gm1, StoreOnExit+DirectPart, i);
         MatrixCol mc(this, mr.Data(), LoadOnEntry, i);
      }
   }
   else
   {
      REPORT
      gm1 = mt.New(ncols,nrows,tm);
      MatrixRow mr(this, LoadOnEntry);
      MatrixCol mc(gm1, StoreOnExit+DirectPart);
      int i = nrows;
      while (i--) { mc.Copy(mr); mr.Next(); mc.Next(); }
   }
   tDelete(); gm1->ReleaseAndDelete(); return gm1;
}
Example #3
0
double pairdist_this_work_mc(const Grid &gsigma, const Grid &density, const Grid &nA, const Grid &n3,
                             const Grid &nbar_sokolowski,  Cartesian r0, Cartesian r1) {
  const Cartesian r01 = Cartesian(r0 - r1);
  const double r = sqrt(r01.dot(r01));
  const double eta0 = gsigma_to_eta(gsigma(r0));
  const double eta1 = gsigma_to_eta(gsigma(r1));
  return (mc(eta0, r, mc_r_step, g) + mc(eta1, r, mc_r_step, g))/2;
}
Example #4
0
int
main()
{
    size_t nelem = sizeof (names) / sizeof (*names);

    printf("Test vertical.\n");
    mc(stdout, nelem, names, 80, false);

    printf("Test horizontal.\n");
    mc(stdout, nelem, names, 80, true);
    return (0);
}
Example #5
0
    V PolymerPropsAd::polymerWaterVelocityRatio(const V& c) const
    {
        const int nc = c.size();
        V mc(nc);

        for (int i = 0; i < nc; ++i) {
            double m = 0;
            polymer_props_.computeMc(c(i), m);
            mc(i) = m;
        }

       return mc;
    }
Example #6
0
void moduleripper (void)
{
	int size;
	uae_u8 *buf, *p;

	size = currprefs.chipmem_size;
	for (int i = 0; i < MAX_RAM_BOARDS; i++) {
		size += currprefs.fastmem[i].size;
		size += currprefs.z3fastmem[i].size;
	}
	size += currprefs.bogomem_size;
	size += currprefs.mbresmem_low_size;
	size += currprefs.mbresmem_high_size;
	buf = p = xmalloc (uae_u8, size);
	if (!buf)
		return;
	memcpy (p, chipmem_bank.baseaddr, currprefs.chipmem_size);
	p += currprefs.chipmem_size;
	for (int i = 0; i < MAX_RAM_BOARDS; i++) {
		mc (p, fastmem_bank[i].start, currprefs.fastmem[i].size);
		p += currprefs.fastmem[i].size;
	}
	mc (p, bogomem_bank.start, currprefs.bogomem_size);
	p += currprefs.bogomem_size;
	mc (p, a3000lmem_bank.start, currprefs.mbresmem_low_size);
	p += currprefs.mbresmem_low_size;
	mc (p, a3000hmem_bank.start, currprefs.mbresmem_high_size);
	p += currprefs.mbresmem_high_size;
	for (int i = 0; i < MAX_RAM_BOARDS; i++) {
		mc (p, z3fastmem_bank[i].start, currprefs.z3fastmem[i].size);
		p += currprefs.z3fastmem[i].size;
	}

	got = 0;
	canceled = 0;
#ifdef _WIN32
	__try {
#endif
		prowizard_search (buf, size);
#ifdef _WIN32
	} __except(ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) {
		write_log (_T("prowizard scan crashed\n"));
	}
#endif
	if (!got)
		notify_user (NUMSG_MODRIP_NOTFOUND);
	else if (!canceled)
		notify_user (NUMSG_MODRIP_FINISHED);
	xfree (buf);
}
Example #7
0
void
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::oneStep( unsigned int i1, unsigned int i2 )
{
  ModuloComputer< int> mc( size() );
  std::vector<double> grad ( getFormerGradient() );
  
  double mid;
  unsigned int i = i1; 
  do 
    {
      unsigned int inext = mc.next( i );
      ValueInfo & vi = this->rw( i );
      double val = vi.oldValue;
      mid = AngleComputer::cast( val - myStep*grad[ i ] );
      if ( AngleComputer::less( mid, vi.min ) ) mid = vi.min;
      if ( AngleComputer::less( vi.max, mid ) ) mid = vi.max;
      vi.value = mid;
      // go to next.
      i = inext;
    }
  while ( i != i2 );

  double E1 = getFormerEnergy( i1, i2 );
  double E2 = getEnergy( i1, i2 );
  if ( E1 <= E2 )
    {
      myStep /= 4.0;
    }
  else
    {
      /* doubling step. */
      myStep *= 2.0;
    }
}
    ColorRectSprite::ColorRectSprite()
    {
        STDMaterial mat;
        mat._base = STDRenderer::white;

        _mat = mc().cache(mat);
    }
Example #9
0
std::vector<cv::Point2f> ShapeFilter::findMassCenter(cv::Mat img){
    //getting the contours
    cv::Mat canny;
    std::vector<std::vector<cv::Point> > contours;
    std::vector<cv::Vec4i> hierarchy;
    cv::Canny(img, canny, 50, 20, 3);
    cv::findContours(canny, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

    double max = 0;
    double area = 0;
    int index = 0;

    std::vector<cv::Moments> mu(contours.size() );
    for(unsigned int i = 0; i < contours.size(); i++ )
    {
        mu[i] = cv::moments( contours[i], false );
        area = cv::contourArea(contours[i]);
        if (area > max){
            max = area;
            index = i;
        }
    }

    //  Get the mass centers:
    std::vector<cv::Point2f> mc( contours.size() );
    for(unsigned int i = 0; i < contours.size(); i++ )
    {mc[i] = cv::Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00 );}

    std::vector<cv::Point2f> result;
    if (max > 0)
        result.push_back(mc[index]);
    return result;
}
int main(int argc, char *argv[])
{
	BoundingBox	bbox(vcg::Point3i(-20, -20, -20), vcg::Point3i(20, 20, 20));
	vcg::Point3i			resolution(40, 40, 40);
	
	Volume	volume;
	Walker	walker(bbox, resolution);

	typedef vcg::tri::MarchingCubes<Mesh, Walker>					MarchingCubes;
	typedef vcg::tri::ExtendedMarchingCubes<Mesh, Walker> ExtendedMarchingCubes;

	
	
	// MARCHING CUBES
	Mesh		mc_mesh;
	printf("[MARCHING CUBES] Building mesh...");
	MarchingCubes					mc(mc_mesh, walker);
	walker.BuildMesh<MarchingCubes>(mc_mesh, volume, mc);
	vcg::tri::io::ExporterPLY<Mesh>::Save( mc_mesh, "marching_cubes.ply");
	printf("OK!\n");

	// EXTENDED MARCHING CUBES
	Mesh		emc_mesh;
	printf("[EXTENDED MARCHING CUBES] Building mesh...");
	ExtendedMarchingCubes emc(emc_mesh, walker, 30);
	walker.BuildMesh<ExtendedMarchingCubes>(emc_mesh, volume, emc);
	vcg::tri::io::ExporterPLY<Mesh>::Save( emc_mesh, "extended_marching_cubes.ply");
	printf("OK!\n");
};
Example #11
0
static void do_command(char *c)
{
	char *token;

	token = get_token(&c);

	if(strcmp(token, "flush") == 0) flush_bridge_cache();

	else if(strcmp(token, "mr") == 0) mr(get_token(&c), get_token(&c));
	else if(strcmp(token, "mw") == 0) mw(get_token(&c), get_token(&c), get_token(&c));
	else if(strcmp(token, "mc") == 0) mc(get_token(&c), get_token(&c), get_token(&c));
	else if(strcmp(token, "crc") == 0) crc(get_token(&c), get_token(&c));
	
	else if(strcmp(token, "ls") == 0) ls();
	else if(strcmp(token, "load") == 0) load(get_token(&c), get_token(&c));
	
	else if(strcmp(token, "serialboot") == 0) serialboot();
	else if(strcmp(token, "netboot") == 0) netboot();
	else if(strcmp(token, "cardboot") == 0) cardboot(0);

	else if(strcmp(token, "mdior") == 0) mdior(get_token(&c));
	else if(strcmp(token, "mdiow") == 0) mdiow(get_token(&c), get_token(&c));

	else if(strcmp(token, "reboot") == 0) reboot();
	
	else if(strcmp(token, "help") == 0) help();
	
	else if(strcmp(token, "") != 0)
		printf("Command not found\n");
}
void getColorTrajectory::detectTrajectory(Mat frame)
{


			resized=frame;
	        cv::Mat hsv_image, detected;
	        cv::medianBlur(resized, resized, 3);//blur the image before changing to HSV
	        cv::cvtColor(resized, hsv_image, cv::COLOR_BGR2HSV);//change from BGR to HSV, easier to detect colors


	        cv::inRange(hsv_image, cv::Scalar(colorDetected.at(0), colorDetected.at(1), colorDetected.at(2)),//detect a color
	        cv::Scalar(colorDetected.at(3), colorDetected.at(4), colorDetected.at(5)), detected);

	        cv::medianBlur(detected, detected,3);//blur again



	        Mat canny_output;
		    vector<vector<Point> > contours;
		    vector<Vec4i> hierarchy;
		    RNG rng(12345);

		    /// Detect edges using canny
		    Canny( detected, canny_output, 100, 100*2, 3 );
		    /// Find contours
		    findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

	    	  /// Draw contours
		    Mat drawing = Mat::zeros( canny_output.size(), CV_8UC3 );
		    for( int i = 0; i< contours.size(); i++ )
		  	 {
		  	     Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
		  	     drawContours( drawing, contours, i, color, 2, 8, hierarchy, 0, Point() );
			 }


		      //saves the contours
	          findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

	          /// Get the moments
	          vector<Moments> mu(contours.size() );
	          if(contours.empty()==false)
	    {
	          for( int i = 0; i < contours.size(); i++ )
	          { mu[i] = moments( contours[i], false ); }

	          ///  Get the mass centers:
	          vector<Point2f> mc( contours.size() );

	          for( int i = 0; i < contours.size(); i++ )
	           { mc[i] = Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00 ); }

	          if((mc[0].x != mc[0].x) == false)//VERY IMPORTANT!!! THIS line delete all the NaN value from the trajectory
	          trajectory.push_back(mc[0]);//only save one contour


	    }


}
Example #13
0
void HoleRepairer::extractIsosurface()
{
    std::vector<double> mcvertexs;
    std::vector<double> mcnormals;
    std::vector<unsigned int> mcfaces;

    MarchingCubes mc(&m_distanceGrid, m_voxelSize, m_boundingBox.limits[0]);
    mc.Initialize(RangValors(2*m_maxDistanceNegative, 0), 1, 0, 1, IJK(VOX_SAMPLES, VOX_SAMPLES, VOX_SAMPLES), false, false);
    mc.Run(mcvertexs, mcnormals, mcfaces);

    std::vector<glm::vec3> vertices;
    std::vector<int>  vtable;
    for (unsigned int i = 0; i < mcvertexs.size(); i+= 3) {
        vertices.push_back(glm::vec3(mcvertexs[i], mcvertexs[i+1], mcvertexs[i+2]));
    }
    for (unsigned int i = 0; i < mcfaces.size(); i++) {
        vtable.push_back(mcfaces[i]);
    }
    m_outMesh = new TriangleMesh();
    m_outMesh->setVertices(vertices, vtable);
    m_outMesh->computeNormalsPerFace();
    m_outMesh->computeBoundingBox();

    std::cout << "    verts: " << mcvertexs.size()/3 << std::endl;
    std::cout << "    faces: " << mcfaces.size()/3 << std::endl;
}
Example #14
0
void CMirrorService::pushMessageToLocalQueueFromMessage( std::vector<TMessageCarrier>& msgQueue, NLNET::CMessage& msgin )
{
	TMessageCarrier mc( true );
	msgQueue.push_back( mc );
	msgin.serial( msgQueue.back().SenderId );
	msgin.serialMemStream( msgQueue.back().Msg );
}
Example #15
0
double 
DGtal::AngleLinearMinimizer::optimize( unsigned int i1, unsigned int i2 )
{
  ASSERT( size() > 2 );
  ModuloComputer< int> mc( size() );

  unsigned int i = i1;
  // (I) first pass to work on old values.
  do 
    {
      ValueInfo & vi = this->rw( i );
      vi.oldValue = vi.value;
      // go to next.
      i = mc.next( i );
    }
  while ( i != i2 );
  this->oneStep( i1, i2 );
  
  mySum = 0.0;
  myMax = 0.0;
  i = i1;
  do 
    {
      const ValueInfo & vi = this->ro( i );
      double diff = fabs( AngleComputer::deviation( vi.value, vi.oldValue ) );
      if ( diff > myMax )
	myMax = diff;
      mySum += diff;
      i = mc.next( i );
    }
  while ( i != i2 );

  return mySum;
}
TEST(MouseControllerUnitTest, CheckConstructor)
{
    Root * root = new Root;
    MouseController mc(root);
    EXPECT_EQ(root, mc.root_);
    root->release();
}
TEST_F(MouseControllerUnitTestBase, ShiftUnexpected)
{
    MouseController mc(root);

    //处理意外情况 没有up直接leave
    MouseEvent down1(kET_MOUSE_DOWN, kMB_LEFT, root,
        Point::Make(45, 45), Point::Make(45, 45), 0);
    mc.handleEvent(down1);
    EXPECT_EQ(v31, mc.capture());
    MouseEvent move1(kET_MOUSE_MOVE, kMB_NONE, root,
        Point::Make(29, 20), Point::Make(29, 20), 0);
    mc.handleEvent(move1);
    EXPECT_EQ(v31, mc.capture());
    MouseEvent leave1(kET_MOUSE_LEAVE, kMB_NONE, root,
        Point::Make(45, 45), Point::Make(45, 45), 0);
    mc.handleEvent(leave1);
    EXPECT_EQ(nullptr, mc.capture());
    EXPECT_EQ(nullptr, mc.over());

    //当前capture 没有mouseable属性
    mc.handleEvent(down1);
    EXPECT_EQ(v31, mc.capture());
    v31->setMouseable(false);
    mc.handleEvent(move1);
    EXPECT_EQ(nullptr, mc.capture());
    EXPECT_EQ(v2, mc.over());
    v31->setMouseable(true);
    //当前capture 被remove
    mc.handleEvent(down1);
    EXPECT_EQ(v31, mc.capture());
    v31->detachFromParent();
    mc.handleEvent(move1);
    EXPECT_EQ(nullptr, mc.capture());
    EXPECT_EQ(v2, mc.over());
}
Example #18
0
	std::list<Instance*> Layer::getInstancesIn(Rect& rec) {
		std::list<Instance*> matching_instances;
		ModelCoordinate mc(rec.x, rec.y);
		m_instanceTree->findInstances(mc, rec.w, rec.h, matching_instances);

		return matching_instances;
	}
Example #19
0
void MethodCreator::forward_method_to(DexMethod* meth, DexMethod* smeth) {
  auto code = meth->get_code();
  if (code != nullptr) {
    meth->set_code(nullptr);
    delete code;
  }
  MethodCreator mc(meth);
  MethodBlock* block = mc.get_main_block();
  std::vector<Location> args;
  auto proto = smeth->get_proto();
  auto rtype = proto->get_rtype();
  auto meth_args = proto->get_args();
  if (meth_args != nullptr) {
    uint16_t arg_count =
        static_cast<uint16_t>(meth_args->get_type_list().size());
    for (auto i = 0; i < arg_count; ++i) {
      args.push_back(mc.get_local(i));
    }
  }
  block->invoke(smeth, args);
  if (rtype == get_void_type()) {
    block->ret_void();
  } else {
    auto ret = mc.make_local(rtype);
    block->move_result(ret, rtype);
    block->ret(ret);
  }
  mc.create();
}
Example #20
0
void MainWindow::createWorldActions()
{
	QDir mc(m_MinecraftPath);
	if (!mc.cd("saves"))
	{
		return;
	}

	QDirIterator it(mc);
	int key = 1;
	while (it.hasNext())
	{
		it.next();
		if (!it.fileInfo().isDir())
		{
			continue;
		}
		QString name = getWorldName(it.filePath().toStdString());
		if (name.isEmpty())
		{
			continue;
		}
		QAction * w = new QAction(this);
		w->setText(name);
		w->setData(it.filePath() + "/region");
		if (key < 10)
		{
			w->setShortcut("Ctrl+" + QString::number(key));
			key++;
		}
		connect(w, SIGNAL(triggered()), this, SLOT(openVanillaWorld()));
		m_WorldActions.append(w);
	}
}
// create a klass of array holding typeArrays
Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
    int dim = dimension();
    assert(dim <= n, "check order of chain");
    if (dim == n)
        return this;

    if (higher_dimension() == NULL) {
        if (or_null)  return NULL;

        ResourceMark rm;
        JavaThread *jt = (JavaThread *)THREAD;
        {
            MutexLocker mc(Compile_lock, THREAD);   // for vtables
            // Atomic create higher dimension and link into list
            MutexLocker mu(MultiArray_lock, THREAD);

            if (higher_dimension() == NULL) {
                Klass* oak = ObjArrayKlass::allocate_objArray_klass(
                                 class_loader_data(), dim + 1, this, CHECK_NULL);
                ObjArrayKlass* h_ak = ObjArrayKlass::cast(oak);
                h_ak->set_lower_dimension(this);
                OrderAccess::storestore();
                set_higher_dimension(h_ak);
                assert(h_ak->oop_is_objArray(), "incorrect initialization of ObjArrayKlass");
            }
        }
    } else {
        CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
    }
    ObjArrayKlass* h_ak = ObjArrayKlass::cast(higher_dimension());
    if (or_null) {
        return h_ak->array_klass_or_null(n);
    }
    return h_ak->array_klass(n, THREAD);
}
Example #22
0
void PD_API MCPackSideChains( WorkSpace& wspace, Physics::Forcefield& ffs, Physics::Forcefield& ff, const Library::RotamerLibrary& rotLib )
{
	// Our moveset
	Manipulator::MoveSet moves( wspace );
	Manipulator::SidechainRotamerLibMove* rotamer = new Manipulator::SidechainRotamerLibMove( wspace, rotLib, 1.0, 1.0 );
	moves.addWithOwnership( rotamer );

	// Minimise only the sidechains
	Protocol::DualFFMinimiser eval(ff, ffs, PickSidechains() );
	eval.SDPreMinSteps = 31;
	eval.StericMinSteps = 501;
	eval.Steps = 501;
	eval.StepSize = 2E1;
	//eval.!OutputLevel = true;
	eval.UpdateScr = 50;
	//eval.UpdateTra = 1;
	//eval.UpdateMon = 10;
	eval.run();

	// Perform a montecarlo procedure
	Protocol::MonteCarlo mc( eval, moves );
	mc.Steps = 10;
	mc.UpdateTra = 1;
	mc.UpdateScr = 1;
	mc.UpdateTraAcc = true;
	//mc.UpdateTraRej = true;
	mc.FinalState = Protocol::MonteCarlo::LowestEpot;
	mc.run(); // Pack sidechains using the rotamers	
}
int a2_makeTemplates(int pdgId, double metCut, double jetptCut, double ptCut, double ecaloCut, double iasCut, TString region){

  sample mc("wjets");
  mc.getTree(fileSR,"chiTrackspreselectionNoQCDCutsNoTrigger");
  mc.getTreeVariables();

  TString filename = Form("templates/IasTemplate_METGt%.0f_JetPtGt%.0f_trackPtGt%.0f_ECaloEq%.0f_pdgId%i.root",metCut,jetptCut,ptCut,ecaloCut,pdgId);
  TFile *out       = new TFile(filename,"RECREATE");

  Double_t xbinsASmi[3]  = {0,iasCut,1};
  TString histoName = (TString) Form("lepton_bkg_data_Iascut_0p%02.0f",iasCut*100);
  cout<<"histoName = "<<histoName<<endl;
  mc.histoASmi   = new TH1D(histoName, histoName, 2, xbinsASmi);
  mc.histoASmi->Sumw2();

  mc.Selection(1, pdgId, 0, 0 , 20., 0.0 , 0 , ecaloCut, 1, region);

  cout<<"Entries: "<<mc.histoASmi->GetEntries()<<endl;
  cout<<"2nd bin: "<<mc.histoASmi->GetBinContent(2)<<" +/- "<<mc.histoASmi->GetBinError(2)<<endl;

  // ***** Calculate scaling factor  ************************************************************************
  mc.histoASmi->Scale(1./mc.histoASmi->Integral());
  // ***********************************************************************************************************

  out->cd();
  mc.histoASmi->Write();
  
  delete mc.histoASmi;
      
  out->Close();
 
  return 0;
}
Example #24
0
int main(int argc, char** argv)
{

    int (*mypt)(int) = &myfun;
    int (&myref)(int) = myfun;
    myclass mc(5);

    // Call to function
    Result<int> r0 = Thread::run(myfun, 0);
    std::cout << "retval:" << r0.value() << std::endl;

    // Call to function pointer
    Result<int> r1 = Thread::run(mypt, 1);
    std::cout << "retval:" << r1.value() << std::endl;

    // Call to function reference
    Result<int> r2 = Thread::run(myref, 2);
    std::cout << "retval:" << r2.value() << std::endl;

    // Call to functor
    Result<int> r3 = Thread::run<int>(mc, 3);
    std::cout << "retval:" << r3.value() << std::endl;

    // Call to member function pointer
    Result<int> r4 = Thread::run(&mc, &myclass::mymember, 4);
    std::cout << "retval:" << r4.value() << std::endl;

    return 0;
}
uint32_t XUDSMessageEndpoint::consume_part_of_message(void *buf, uint32_t count)
{
	XUDSMessageEndpoint::MessageConsumer mc(buf, count, false);
	zq_consume(zq, &mc);
	lite_assert(mc.out_actual!=(uint32_t)-1);
	return mc.out_actual;
}
void WaveformBlockFilter::
        test()
{
    // It should update a block with cwt transform data.
    {
        Timer t;

//        Tfr::DrawnWaveform waveformdesc;
//        Signal::Interval data = waveformdesc.requiredInterval (Signal::Interval(0,4), 0);

        Signal::Interval data(0,4);
        // Create some data to plot into the block
        Signal::pMonoBuffer buffer(new Signal::MonoBuffer(data, data.count ()/4));
        float *p = buffer->waveform_data()->getCpuMemory ();
        srand(0);
        for (unsigned i=0; i<buffer->getInterval ().count (); ++i) {
            p[i] = -1.f + 2.f*rand()/RAND_MAX;
        }

        // Create a block to plot into
        BlockLayout bl(4,4, buffer->sample_rate ());
        VisualizationParams::ptr vp(new VisualizationParams);

        Reference ref = [&]() {
            Reference ref;
            Position max_sample_size;
            max_sample_size.time = 2.f*max(1.f, buffer->length ())/bl.texels_per_row ();
            max_sample_size.scale = 1.f/bl.texels_per_column ();
            ref.log2_samples_size = Reference::Scale(
                        floor_log2( max_sample_size.time ),
                        floor_log2( max_sample_size.scale ));
            ref.block_index = Reference::Index(0,0);
            return ref;
        }();

        Heightmap::pBlock block( new Heightmap::Block(ref, bl, vp));

        // Create some data to plot into the block
        Tfr::ChunkAndInverse cai;
        cai.input = buffer;

        // Do the merge
        Heightmap::MergeChunk::ptr mc( new WaveformBlockFilter );
        Update::IUpdateJob::ptr job = mc->prepareUpdate (cai)[0];

        EXCEPTION_ASSERT(dynamic_cast<WaveformBlockUpdater::Job*>(job.get ()));

        std::queue<Heightmap::Update::UpdateQueue::Job> jobs;
        Heightmap::Update::UpdateQueue::Job j;
        j.updatejob = job;
        j.intersecting_blocks = vector<pBlock>{block};
        jobs.push (std::move(j));

        WaveformBlockUpdater().processJobs(jobs);

        float T = t.elapsed ();
        EXCEPTION_ASSERT_LESS(T, 1.0); // this is ridiculously slow
    }
}
Example #27
0
void CMirrorService::pushMessageToLocalQueue( std::vector<TMessageCarrier>& msgQueue, TServiceId senderId, NLMISC::CMemStream& msg )
{
	TMessageCarrier mc( true );
	msgQueue.push_back( mc );
	msgQueue.back().SenderId = senderId;
	msgQueue.back().Msg = msg;
	//nldebug( "Received msg from %s for local %s", servStr(senderId).c_str(), servStr(destId).c_str() );
}
void mc_test ( )

/******************************************************************************/
/*
  Purpose:

    MC_TEST tests MC.

  Licensing:

    This code is distributed under the GNU LGPL license.

  Modified:

    18 February 2012

  Author:

    John Burkardt
*/
{
  double *conf;
  double e;
  int m;
  double r;
  double s0;
  int seed;
  double sigma;
  double t1;

  printf ( "\n" );
  printf ( "MC_TEST:\n" );
  printf ( "  A demonstration of the Monte Carlo method\n" );
  printf ( "  for option valuation.\n" );

  s0 = 2.0;
  e = 1.0;
  r = 0.05;
  sigma = 0.25;
  t1 = 3.0;
  m = 1000000;
  seed = 123456789;

  printf ( "\n" );
  printf ( "  The asset price at time 0, S0    = %g\n", s0 );
  printf ( "  The exercise price         E     = %g\n", e );
  printf ( "  The interest rate          R     = %g\n", r );
  printf ( "  The asset volatility       SIGMA = %g\n", sigma );
  printf ( "  The expiry date            T1    = %g\n", t1 );
  printf ( "  The number of simulations  M     = %d\n", m );

  conf = mc ( s0, e, r, sigma, t1, m, &seed );

  printf ( "\n" );
  printf ( "  The confidence interval is [%g,%g].\n", conf[0], conf[1] );

  return;
}
XUDSMessageEndpoint::~XUDSMessageEndpoint()
{
	while (!zq_is_empty(zq))
	{
		// drop unread messages. Should probably warn loudly when this happens.
		XUDSMessageEndpoint::MessageConsumer mc(NULL, 0, true);
		zq_consume(zq, &mc);
	}
}
Example #30
0
void Model::update(wxPoint point, wxBitmap set)
{
	wxMemoryDC mc(*img);
	mc.DrawBitmap(set,point);
	mc.DrawBitmap(player->GetCurrentImage(),player->GetPosition().x,player->GetPosition().y, true);
	for(int i = 0; i < monsters.size(); i++)
		mc.DrawBitmap(monsters[i]->GetCurrentImage(),monsters[i]->GetPosition().x,monsters[i]->GetPosition().y, true);
	//img->SaveFile("Image/Test.png", wxBITMAP_TYPE_PNG);
}