Exemplo n.º 1
0
int main()
{
	start = clock();
	MyFunction();
	stop = clock();
	duration = ((double)(stop - start))/CLK_TCK;
	
	return 0; 
}
int main(int argc, char * argv[] ) {
    a=5;
    b=2;

    #pragma offload target(mic) in (a, b) out (sum)
    {
        MyFunction();
    }

    printf("sum %f \n", sum);
}
Exemplo n.º 3
0
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: разместите код здесь.

	LoadMyFunction();
	int iCode1 = MyFunction();

    // »нициализаци¤ глобальных строк
    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    LoadStringW(hInstance, IDC_LAB15STATIC, szWindowClass, MAX_LOADSTRING);
    MyRegisterClass(hInstance);

    // ¬ыполнить инициализацию приложени¤:
    if (!InitInstance (hInstance, nCmdShow))
    {
        return FALSE;
    }

    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB15STATIC));

    MSG msg;

    // ÷икл основного сообщени¤:
    while (GetMessage(&msg, nullptr, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}
void ribi::QtTestPlaneInvestigateAccuracyRibiDialog::OnAnyChange()
{
  try { boost::lexical_cast<double>(ui->edit_minx->text().toStdString()); }
  catch (boost::bad_lexical_cast&)
  {
    this->setWindowTitle("Value of x_min is not a valid double"); return;
  }
  try { boost::lexical_cast<double>(ui->edit_miny->text().toStdString()); }
  catch (boost::bad_lexical_cast&)
  {
    this->setWindowTitle("Value of y_min is not a valid double"); return;
  }
  try { boost::lexical_cast<double>(ui->edit_maxx->text().toStdString()); }
  catch (boost::bad_lexical_cast&)
  {
    this->setWindowTitle("Value of x_max is not a valid double"); return;
  }
  try { boost::lexical_cast<double>(ui->edit_maxy->text().toStdString()); }
  catch (boost::bad_lexical_cast&)
  {
    this->setWindowTitle("Value of y_max is not a valid double"); return;
  }

  const double x_min = boost::lexical_cast<double>(ui->edit_minx->text().toStdString());
  const double y_min = boost::lexical_cast<double>(ui->edit_miny->text().toStdString());
  const double x_max = boost::lexical_cast<double>(ui->edit_maxx->text().toStdString());
  const double y_max = boost::lexical_cast<double>(ui->edit_maxy->text().toStdString());

  if (x_min >= x_max)
  {
    this->setWindowTitle("Value of x_min must be smaller than x_max"); return;
  }

  if (y_min >= y_max)
  {
    this->setWindowTitle("Value of y_min must be smaller than y_max"); return;
  }

  typedef boost::geometry::model::point<double,3,boost::geometry::cs::cartesian> Coordinat3D;

  const boost::shared_ptr<Plane> plane(
    CreatePlane()
  );
  assert(plane);

  struct MyFunction : public QtSurfacePlotWidget::Function
  {
    typedef std::function<Coordinat3D(const double x, const double y)> ConvertFunction;

    MyFunction(
      const Plane& plane,
      const ConvertFunction& f
      ) : m_f(f), m_plane(plane) {}
    double operator()(const double x, const double y) const noexcept
    {
      const auto co_double = m_f(x,y);
      const Plane::Coordinat3D co_apfloat(
        apfloat(boost::geometry::get<0>(co_double)),
        apfloat(boost::geometry::get<1>(co_double)),
        apfloat(boost::geometry::get<2>(co_double))
      );
      const auto error_apfloat = m_plane.CalcError(co_apfloat);
      return Geometry().ToDoubleSafe(error_apfloat);
      //return m_plane.CalcError(m_f(x,y));
    }
    private:
    const ConvertFunction m_f;
    const Plane& m_plane;
  };

  m_widget_x->Plot(
    MyFunction(*plane,[](const double x, const double y) { return Coordinat3D(0.0,x,y); }),
    x_min, x_max,
    y_min, y_max
  );

  m_widget_y->Plot(
    MyFunction(*plane,[](const double x, const double y) { return Coordinat3D(x,0.0,y); }),
    x_min, x_max,
    y_min, y_max
  );

  m_widget_z->Plot(
    MyFunction(*plane,[](const double x, const double y) { return Coordinat3D(x,y,0.0); }),
    x_min, x_max,
    y_min, y_max
  );

  this->setWindowTitle("Function plotted successfully");

}
Exemplo n.º 5
0
 virtual void RunTest (testing::TestResult& result_)
 {
     EXPECT_EQ (1, MyFunction());
 }
Exemplo n.º 6
0
int main(int argc, char* argv[]) {
    std::cout<<MyFunction(42);
    return 0;
}
Exemplo n.º 7
0
 virtual void RunTest (TestResult& result_)
 {
     CHECK_EQUAL (1, MyFunction());
 }
Exemplo n.º 8
0
    virtual void RunTest (TestResult& result_)
    {
		CHECK_ASSERT( MyFunction() );
    }
Exemplo n.º 9
0
int main(int argc, char* argv[])
{
  MyFunction();

  return 0;
}
Exemplo n.º 10
0
int main(int argc, char* argv[]) {

	if (argc < 2) {
		std::cout << "Usage: simpleReact num_particles" << std::endl;
		exit(-1);
	}

	const unsigned int num_particles = atoi(argv[1]);

	std::ofstream tf;
	tf.open(("output/time_simpleReact_"+std::string(argv[1])+".dat").c_str());
	boost::progress_timer t(tf);

	const double end_time = 5.0;
	const double dt = 0.001;

	/*
	 * Create "red" species with D=1
	 */
	Species red(0.1);
	//red.fill_uniform(0.0,1.0,1);

	/*
	 * create diffusion operator and apply to red species
	 */
	Diffusion bd; bd.add_species(red);

	/*
	 * Create simulation boundary planes
	 */
	AxisAlignedPlane<0> xlow(0,1);
	AxisAlignedPlane<0> xhigh(1,-1);
	AxisAlignedPlane<1> ylow(0,1),yhigh(1,-1);
	AxisAlignedPlane<2> zlow(0,1),zhigh(1,-1);

	/*
	 * Create input flux boundary
	 */
	FluxBoundary fb(Vect3d(1,0,0),Vect3d(0,1,0),Vect3d(0,0,1),num_particles); fb.add_species(red);

	/*
	 * Create jump (periodic) boundaries
	 */
	//JumpBoundary<AxisAlignedPlane<0> > jb1(xlow,Vect3d(1,0,0)); jb1.add_species(red);
	JumpBoundary<AxisAlignedPlane<1> > jb2(ylow,Vect3d(0,1,0)); jb2.add_species(red);
	JumpBoundary<AxisAlignedPlane<2> > jb3(zlow,Vect3d(0,0,1)); jb3.add_species(red);
	JumpBoundary<AxisAlignedPlane<1> > jb4(yhigh,Vect3d(0,-1,0)); jb4.add_species(red);
	JumpBoundary<AxisAlignedPlane<2> > jb5(zhigh,Vect3d(0,0,-1)); jb5.add_species(red);

	/*
	 * Create reflective boundary
	 */
	ReflectiveBoundary<AxisAlignedPlane<0> > rb(xhigh); rb.add_species(red);

	/*
	 * Create unimolecular reaction operator (red -> 0)
	 */
	UniMolecularReaction dr(1,red >> 0);

	const double h_in = 0.1;
	StructuredGrid out_grid(Vect3d(0,0,0), Vect3d(1,1,1), Vect3d(h_in,1.0,1.0));
	OutputConcentrations out_concen_1d("output/simpleReact_",end_time/100.0, out_grid);out_concen_1d.add_species(red);

	OutputCompareWithFunction<rmsError<MyFunction> > out_compare("output/simpleReact_error",end_time/100.0,0,1,out_grid,
			rmsError<MyFunction>(MyFunction(num_particles,red.D))); out_compare.add_species(red);

	Plot2d plot(0,out_concen_1d.get_data("x"),out_concen_1d.get_data("Concentration"),"x","Concentration","My first plot");

	Visualisation vis(0);vis.add_species(red);
	   vis.add_geometry(xlow);
	   vis.add_geometry(xhigh);
	   vis.add_geometry(ylow);
	   vis.add_geometry(yhigh);
	   vis.add_geometry(zlow);
	   vis.add_geometry(zhigh);

	/*
	 * Run simulation until end_time with timestep dt
	 */
	run(red, end_time, dt, bd, fb, jb2, jb3, jb4, jb5, rb, dr, out_concen_1d, out_compare, vis,plot);

	std::vector<int> bins;
	make_histogram(bins,red,100, 0,1);

	std::ofstream f;
	f.open(("output/simpleReact_"+std::string(argv[1])+".dat").c_str());
	f << end_time << ' ';
	BOOST_FOREACH(int x,bins) {
		f << x <<' ';
	}
	f << std::endl;
	f.close();


	return EXIT_SUCCESS;
}