Ejemplo n.º 1
0
int main(int,char** argv)
{
 
  auto solar_system = construct_tuple(sun,jupiter,saturn,uranus,neptune);
  offset(solar_system);

  printf ("%.9f\n", energy(solar_system));
  
  int n = atoi(argv[1]);
  
  for (int i = 1; i <= n; i++)
  {
    advance(solar_system);
  }

  printf ("%.9f\n", energy(solar_system));

  return 0;
}
Ejemplo n.º 2
0
void heartbeat(struct reb_simulation* r){
	if (r->t > next_output){
		next_output *= 1.02;
		reb_integrator_synchronize(r);
		FILE* f = fopen("energy.txt","a");
		double e = energy(r);
		fprintf(f, "%e %.16e\n", r->t, fabs((e-e_init)/e_init));
		fclose(f);
	}
}
Ejemplo n.º 3
0
 EnergyGradAndPrecond energy_grad_and_precond(const Vector &x) const {
   EnergyGradAndPrecond egpg;
   egpg.energy = energy(x);
   egpg.grad = grad(x);
   egpg.precond = grad(x);
   const int sz = x.get_size();
   for (int i=0; i<sz; i++) {
     egpg.precond[i] /= spring(i);
   }
   return egpg;
 }
Ejemplo n.º 4
0
void problem_output(){
	if (output_check(10000.)){
		output_timing();
		integrator_synchronize();
		FILE* f = fopen("energy.txt","a");
		double e = energy();
		fprintf(f,"%e %e %e\n",t, fabs((e-e_init)/e_init), tools_megno());
		fclose(f);
		printf("  Y = %.3f",tools_megno());
	}
}
Ejemplo n.º 5
0
tarch::la::Vector<NUMBER_OF_EULER_UNKNOWNS, double> peanoclaw::solver::euler3d::Cell::getUnknowns() const {
  tarch::la::Vector<NUMBER_OF_EULER_UNKNOWNS, double> unknowns;
  unknowns[0] = density();
  unknowns[1] = _data[1];
  unknowns[2] = _data[2];
  unknowns[3] = _data[3];
  unknowns[4] = energy();
  unknowns[5] = marker();

  return unknowns;
}
Ejemplo n.º 6
0
	int superMi::tuetee_mapping(Solid* mesh, double deltaE, double deltaT)
	{
		double oldEnergy = 0;
		double newEnergy = 0;
		int error = 0;
		bool flag = false;

		error = energy(mesh, &oldEnergy, TUETEE);
		std::cout << "Initial Tuette energy: " << oldEnergy << std::endl;
		for (int i = 0; (i < 100000) && !flag; i++){
			error = gradient(mesh, TUETEE);
			error = absolute_derivative(mesh);
			error = update_mesh(mesh, deltaT);
			error = energy(mesh, &newEnergy, TUETEE);
			if (i % 1000 == 0) std::cout << i + 1 << ": " << newEnergy << std::endl;
			error = check_energy_change(&oldEnergy, &newEnergy, deltaE, &flag);
		}

		return 0;
	}
Ejemplo n.º 7
0
void caller()
{
    int i;
    float *d;
    InteractionMatrix *jMatrices;
    d = (float*)malloc(sizeof(float)*3*3*15);
    for (i = 0; i < 15*9; i++) d[i] = i;
    jMatrices = (InteractionMatrix *)(d);
    printf("d=%p,jMatrices=%p\n",d,jMatrices);
    energy(jMatrices[3]);
}
Ejemplo n.º 8
0
/*
   This program computes first order directional derivatives 
   for the helmholtz energy function */
int main(int argc, char *argv[]) {
    int nf, n, j, l;
    double result1, result2;
    double q, jd, r;
    double *x, *bv;

    fprintf(stdout,"HELM-DIFF-EXAM (ADOL-C Example)\n\n");
    fprintf(stdout," # of independents/10 =? \n ");
    scanf("%d",&nf);

    /*--------------------------------------------------------------------------*/
    n = 10 * nf;                                            /* Initilizations */
    x   = (double*) malloc(n*sizeof(double));
    bv  = (double*) malloc(n*sizeof(double));

    r = 1.0/n;
    for (j=0; j<n; j++) {
        jd     = j;
        bv[j]  = 0.02*(1.0+fabs(sin(jd)));
        x[j]   = r*sqrt(1.0+jd);
    }

    /*--------------------------------------------------------------------------*/
    result2 = energy(n,x,bv);                                    /* basepoint */
    fprintf(stdout,"%14.6E -- energy\n",result2);

    /*--------------------------------------------------------------------------*/
    for (l=0; l<n; l++)                            /* directional derivatives */
    { x[l]    = x[l]+delta;
        result1 = energy(n,x,bv);
        x[l]    = x[l]-delta;
        q       = (result1-result2)/delta;
        fprintf(stdout,"%3d: %14.6E,  \n",l,q);
    }
    fprintf(stdout,"%14.6E -- energy\n",result2);

    free((char*) bv);
    free((char*) x);

    return 0;
}
Ejemplo n.º 9
0
bool uhfsolve::convergenceCriteria(){
    //Evaluate convergence conditions
    bool condition = true;
    if(iterations>5000){
        condition = false;
    }
    if(abs(energyPrev-energy())<tolerance){

        condition = false;
    }
    return condition;
}
Ejemplo n.º 10
0
	int superMi::harmonic_mapping(Solid* mesh, double deltaE, double deltaT)
	{
		double oldEnergy = 0;
		double newEnergy = 0;
		int error = 0;
		bool flag = false;

		error = energy(mesh, &oldEnergy, HARMONIC);
		std::cout << "Initial Harmonic energy: " << oldEnergy << std::endl;
		for (int i = 0; (i < 13) && !flag; i++){
			error = gradient(mesh, HARMONIC);
			error = absolute_derivative(mesh);
			error = update_mesh(mesh, deltaT);
			error = mass_center(mesh);
			error = energy(mesh, &newEnergy, HARMONIC);
			if (i % 1 == 0) std::cout << i + 1 << ": " << newEnergy << std::endl;
			error = check_energy_change(&oldEnergy, &newEnergy, deltaE, &flag);
		}

		return 0;
	}
Ejemplo n.º 11
0
//---------------------------------------------
double CpxCrvletPrtd::globalenergy()
{
  double lclsum = 0;
  vector< vector<int> >& c = _nx;
  for(int s=0; s<c.size(); s++)
	 for(int w=0; w<c[s].size(); w++)
		if(_owners[s][w]==mpirank())
		  lclsum += energy(_blocks[s][w]);
  double glbsum = 0;
  iC( MPI_Reduce((void*)(&lclsum), (void*)(&glbsum), 1, MPI_DOUBLE, MPI_SUM, 0, PETSC_COMM_WORLD) );
  return glbsum;
}
Ejemplo n.º 12
0
void problem_init(int argc, char* argv[]) {
    // Setup constants
    integrator	= WHFAST;
    dt 		= 0.001*2.*M_PI;			// initial timestep (in days)
    init_boxwidth(200);

    // Initial conditions

    {
        struct particle p = {.m=1.,.x=0,.y=0.,.z=0.,.vx=0,.vy=0.,.vz=0.};
        particles_add(p);
    }
    {
        double e = 0.999;
        struct particle p = {.m=0.,.x=0.01,.y=0.,.z=0.,.vx=0,.vy=0.*sqrt((1.+e)/(1.-e)),.vz=0.};
        particles_add(p);
    }
    tools_move_to_center_of_momentum();
    //problem_additional_forces 	= additional_forces;
    // Add megno particles
    //tools_megno_init(1e-16);  // N = 6 after this function call.
    system("rm -f *.txt");
    ei = energy();
}

void additional_forces() {
    particles[1].ax += 0.12/6.;
}

double energy() {
    double e_kin = 0.;
    double e_pot = 0.;
    struct particle pi = particles[1];
    e_kin += 0.5 * (pi.vx*pi.vx + pi.vy*pi.vy + pi.vz*pi.vz);
    struct particle pj = particles[0];
    double dx = pi.x - pj.x;
    double dy = pi.y - pj.y;
    double dz = pi.z - pj.z;
    e_pot -= G*pj.m/sqrt(dx*dx + dy*dy + dz*dz);
    return e_kin +e_pot;
}
int no =0;
void problem_output() {
    no++;
//	printf("%d\n", no);
    if (output_check(1000.*dt)) {
        output_timing();
    }
//	FILE* f = fopen("Y.txt","a+");
//	fprintf(f,"%e %e %e\n",t,(energy()-ei)/ei,tools_megno());
//	fclose(f);
}
CoordType SpatialModelMaximalRepulsion3D<CoordType>::computeBeta()
{
  const int n = 100;
  const int numPoints = this->getHardcoreDistances().getSize();
  const CoordType maxRadius = this->getTriMesh().equivalentRadius() / 50.0;
  RandomGenerator& randomGenerator = this->getRandomGenerator();
  Vertices<CoordType> vertices1;
  Vertices<CoordType> vertices2;
  CoordType sumDelta = 0.0;

  for (int i = 0; i < n; ++i)
  {
    vertices1 = SpatialModelHardcoreDistance3D<CoordType>::drawSample( numPoints );
    vertices2 = vertices1;
    vertices2.detach();
    int v = randomGenerator.uniformL( numPoints );
    moveVertex( vertices2, v, maxRadius );
    sumDelta += fabs( energy(vertices1) - energy(vertices2) );
  }

  return log( 20.0 ) / ( sumDelta/n );
}
Ejemplo n.º 14
0
TEST(podio, Basics) {
  auto store = podio::EventStore();
  // Adding
  auto& collection = store.create<ExampleHitCollection>("name");
  auto hit1 = collection.create(0.,0.,0.,0.); //initialize w/ value
  auto hit2 = collection.create(); //default initialize
  hit2.energy(12.5);
  // Retrieving
  const ExampleHitCollection* coll2(nullptr);
  bool success = store.get("name",coll2);
  const ExampleHitCollection* coll3(nullptr);
  if (store.get("wrongName",coll3) != false) success = false;
  EXPECT_EQ(true, success);
}
static PyObject *
energy_wrapped(PyObject *self, PyObject *args)
{
    float mass, e;

    if (!PyArg_ParseTuple(args, "f:energy", &mass))
    {
        return NULL;
    }
    
    e = energy(mass);
    
    return Py_BuildValue("f", e);
}
Ejemplo n.º 16
0
int main(int argc, char **argv){
    double* q_x = calloc(2, sizeof(double));
    double* q_y = calloc(2, sizeof(double));
    printf("Intial position in x : ");
    scanf("%lf",&q_x[0]);
    printf("Intial velocity in y : ");
    scanf("%lf",&q_y[1]);
    FILE *f = fopen("output.txt","w");
    FILE *f_1 = fopen("out3.txt","w");
    //q_x[0] = 1.0; // position
    q_x[1] = 0.0; // momentum 
    q_y[0] = 0.0;
    //q_y[1] = 1.0;

    int n = 10000;
    double h = (2*PI)/n;
    double int_E = energy(sqrt(pow(q_x[0],2) + pow(q_y[0],2)),q_x[1],q_y[1]);
    double int_L = angular_momentum(q_x[0],q_y[0],q_x[1],q_y[1]);
    fprintf(f,"x \t y \t R  \n");
    fprintf(f_1,"%s \t %s \t %s \t %s \t %s\n","Time","E","L","Deviation in E","Deviation in L");
    for (int i = 0;i<=n;i++){
        double radius = sqrt(pow(q_x[0],2) + pow(q_y[0],2));
        double theta = atan2(q_y[0],q_x[0]);
        double E = energy(radius,q_x[1],q_y[1]);
        double L = angular_momentum(q_x[0],q_y[0],q_x[1],q_y[1]);
        fprintf(f,"%f \t %f \t %f\n",q_x[0] ,q_y[0],radius);
        fprintf(f_1,"%.5e \t %.5e \t %.5e\t",i*h,E,L);
        fprintf(f_1,"%.6e \t %.16e\n",fabs(E-int_E), fabs(L-int_L));
        PERLF(q_x,force_x,h,radius);
        PERLF(q_y,force_y,h,radius);
        

    }
    fclose(f);
    return 0;

}
Ejemplo n.º 17
0
Archivo: nbody.c Proyecto: arowM/felix
int main(int argc, char ** argv)
{
    int n = 50000000;
    int i;
    clock_t t0, t1;
    double r0, r1;

    t0 = clock();

    offset_momentum(NBODIES, bodies);
    r0 = energy(NBODIES, bodies);

    for (i = 1; i <= n; i++)
        advance(NBODIES, bodies, 0.01);
    r1 = energy(NBODIES, bodies);

    t1 = clock();

    printf("%.9f\n", r0);
    printf("%.9f\n", r1);
    printf("%f\n", ((double) (t1 - t0)) / CLOCKS_PER_SEC);

    return 0;
}
Ejemplo n.º 18
0
TEST(podio,looping) {
  bool success = true;
  auto store = podio::EventStore();
  auto& coll  = store.create<ExampleHitCollection>("name");
  auto hit1 = coll.create(0.,0.,0.,0.);
  auto hit2 = coll.create(1.,1.,1.,1.);
  for(auto i = coll.begin(), end = coll.end(); i != end; ++i) {
    auto energy = i->energy();
  }
  for(int i = 0, end = coll.size(); i != end; ++i) {
    auto energy = coll[i].energy();
  }
  if ((coll[0].energy() != 0) || (coll[1].energy() != 1)) success = false;
  EXPECT_EQ(true, success);
}
Ejemplo n.º 19
0
string Particle::toString() const {
	stringstream out;
	out << "Particle information" << "\n";
	out << setw(30) << "energy" << setw(30) << "px" << setw(30) << "py" << setw(30) << "pz" << "\n";
	out << setw(30) << energy() << setw(30) << px() << setw(30) << py() << setw(30) << pz() << "\n";
	out << setw(30) << "phi" << setw(30) << "eta" << setw(30) << "theta" << setw(30) << "  " << "\n";
	out << setw(30) << phi() << setw(30) << eta()  << setw(30) << theta() << setw(30) << " " << "\n";
	out << setw(30) << "momentum" << setw(30) << "E_T" << setw(30) << "p_T" << setw(30) << "  " << "\n";
	out << setw(30) << momentum() << setw(30) << et() << setw(30) << pt() << setw(30) << "  " << "\n";
	out << setw(30) << "m_dyn" << setw(30) << "m_fix" << setw(30) << "charge" << setw(30) << "  " << "\n";
	out << setw(30) << massFromEnergyAndMomentum() << setw(30) <<  mass() << setw(30) << charge() << setw(30) << "  " << "\n";
	out << setw(30) << "d0 =" << setw(30) << "d0_bs" << setw(30) << "  " << setw(30) << "  " << "\n";
	out << setw(30) << d0() << setw(30) << d0_wrtBeamSpot() << setw(30) << "  " << setw(30) << "  " << "\n";
	return out.str();
}
Ejemplo n.º 20
0
void MainWindow::imageRestore(){
    for(int i = 0; i < NT; i++){
        for(int j = 0; j < NT; j++){
            restored[i][j] = noisy[i][j];
        }
    }

    double beta = beta_max / (double)nbeta, d_action, naccept, nreject;
    for(int count = 0; count < nbeta; count++){
        for(int i = 0; i < NT; i++){
            for(int j = 0; j < NT; j++){
                restored[i][j] *= -1.0;
                d_action = energy(i,j,beta);
                restored[i][j] *= -1.0;
                d_action -= energy(i,j,beta);

                if(d_action > 0 || exp(d_action) > genrand()){
                    restored[i][j] *= -1.0;
                }
            }
        }
        beta += beta_max / (double)nbeta;
    }
}
////////THE BOSS OF INTEGRATOR AND EXIT DATES//////////
int emulator(void)
{
  int i,l,par_proc[size+2];
  double Ttotal,time;
  
  Ttotal = t*Num_simulation*Num_archive;
  if(rank == 0)  printf("\nTotal time of simulation =%lf\n\n",Ttotal);

  time=0.0;

  Num_par_proc_division(par_proc); //PARTICLES FOR PROCESSOR
 

  ////THIS "for" GENERATE "Num_archive" ARCHIVES WHIT POSITION AND VELOCITY
  for(i=0 ; i<Num_archive ; i++)
    {
      for (l=0; l<Num_simulation; l++) ///NUMBER OF SIMULATION IN ONE ARCHIVE
	{ 
	  if(l%10==0)  energy(time,par_proc); //ENERGY CALCULATION

	  if(rank == 0) printf("Time of Simulation: %lf\n",time);

	  if(INTEGRATOR==0)
	    { ////SYMPLECTIC INTEGRATION//
	      symplectic_integration(par_proc);
	    }
	  else if (INTEGRATOR==1)
	    { ////RK4 INTEGRATION ////////
	      RK4_integration(par_proc); 
	    }
	  else
	    { ////SYMPLECTIC INTEGRATION//
	      symplectic_integration2(par_proc);
	    }

	  time=time + t;	
	}

      centermasspos(par_proc); //CENTER MASS POSITIONS
      centermassvel(par_proc); //CENTER MASS VELOCITIES

      if(rank == 0)  write_output(i); //WRITE OUTPUT ARCHIVE i-esimo

    }

  return 0;
}
Ejemplo n.º 22
0
	void PostureIKSolver::computeGredient(){
		double energyO = energy();
		
		gredient[0] = 0;
		gredient[1] = 0;
		gredient[2] = 0;
		
		zh::Skeleton::BoneIterator bi = mSkel -> getBoneIterator();
		int boneCounter = 0;
		//gredient for root position
		/*GoalConstIterator gi = getGoalConstIterator();
		while(!gi.end()){
			IKGoal goal = gi.next();
			gredient[0] += 2 * (mSkel->getBone(goal.boneId)->getWorldPosition() - goal.position).x;
			gredient[1] += 2 * (mSkel->getBone(goal.boneId)->getWorldPosition() - goal.position).y;
			gredient[2] += 2 * (mSkel->getBone(goal.boneId)->getWorldPosition() - goal.position).z;
		}*/

		bi = mSkel -> getBoneIterator();
		Bone* bone = bi.next();
		Vector3 snap = bone ->getPosition();
		bone -> setPosition(snap + Vector3(step,0,0));
		gredient[0] = (energy() - energyO) / step;
		
		bone -> setPosition(snap + Vector3(0,step,0));
		gredient[1] = (energy() - energyO) / step;
		
		bone -> setPosition(snap + Vector3(0,0,step));
		gredient[2] = (energy() - energyO) / step;
		bi = mSkel -> getBoneIterator();
		bone -> setPosition(snap);

		while(!bi.end()){
				Bone* bone = bi.next();
				Quat snap = bone -> getOrientation();
				//x rotation
				bone -> setOrientation(snap*(Quat(0,step,0,0).exp()));
				gredient[boneCounter * 3 + 3] = (energy() - energyO) / step;
				//y rotation
				bone -> setOrientation(snap*(Quat(0,0,step,0).exp()));
				gredient[boneCounter * 3 + 4] = (energy() - energyO) / step;
				//z rotation
				bone -> setOrientation(snap*(Quat(0,0,0,step).exp()));
				gredient[boneCounter * 3 + 5] = (energy() - energyO) / step;
				//reset orientation
				bone -> setOrientation(snap);
				boneCounter++;
		}
	}
Ejemplo n.º 23
0
//finds the energy of each pixel in the image and stores it
void computeImageEnergy() {
    int x, y, i, j, tempc, offset = 0;
    double *my_img_energy;
    double *temp_img_energy;

    my_img_energy = (double *)malloc(my_epixels_c * sizeof(double));
    //compute the energy of my pixels
    for (i = my_epixels_offset; i < my_epixels_offset + my_epixels_c; i++) {
        x = i / initial_height;
        y = i % initial_height;
        if (x > current_width || y > current_height) {
            //printf("skipped\n");
            my_img_energy[i - my_epixels_offset] = image_energy[i];
        }
        //printf("%d %d\n", x * initial_height + y, i);
        //printf("%d %d %d\n", rank, x, y);
        image_energy[i] = energy(x, y);
        my_img_energy[i - my_epixels_offset] = image_energy[i];
    }

    //send and receive data to and from each process to update image_energy for self
    for (i = 0; i < numprocs; i++) {
        if (rank == i) {
            offset += my_epixels_c;
            continue;
        }
        if (i > 1) {
            offset += energy_pixels[i - 1];
        }
        if (i == 1 && rank != 0) {
            offset += energy_pixels[0];
        }
        tempc = energy_pixels[i];
        temp_img_energy = (double *)malloc(tempc * sizeof(double));
        //printf("%d send %d pixels and recv %d pixels from %d\n", rank, my_epixels_c, energy_pixels[i], i);
        MPI_Sendrecv(my_img_energy, my_epixels_c, MPI_DOUBLE, i, 0, temp_img_energy, tempc, MPI_DOUBLE, i, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
    
        for (j = 0; j < tempc; j++) {
            //printf("%d %d\n", rank, offset + j);
            //printf("%d %d %lf\n", rank, offset + j, image_energy[offset + j]);
            image_energy[offset + j] = temp_img_energy[j];
        }
        free(temp_img_energy);
    }
    free(my_img_energy);
}
Ejemplo n.º 24
0
TEST(podio,referencing) {
  bool success = true;
  auto store = podio::EventStore();
  auto& hits  = store.create<ExampleHitCollection>("hits");
  auto hit1 = hits.create(0.,0.,0.,0.);
  auto hit2 = hits.create(1.,1.,1.,1.);
  auto& clusters  = store.create<ExampleClusterCollection>("clusters");
  auto  cluster  = clusters.create();
  cluster.addHits(hit1);
  cluster.addHits(hit2);
  int index = 0;
  for (auto i = cluster.Hits_begin(), end = cluster.Hits_end(); i!=end; ++i){
    if( i->energy() != index) success = false;
    ++index;
  }
  EXPECT_EQ(true, success);
}
Ejemplo n.º 25
0
glm::vec3 Material::EvaluateScatteredEnergy(const Intersection &isx, const glm::vec3 &woW, const glm::vec3 &wiW, BxDFType flags) const
{
    glm::vec3 woL, wiL;
    glm::vec3 bit = isx.bitangent;
    glm::vec3 tan = isx.tangent;
    glm::vec3 nor = isx.normal;
    woL = glm::vec3(glm::dot(woW, tan), glm::dot(woW, bit), glm::dot(woW, nor));
    wiL = glm::vec3(glm::dot(wiW, tan), glm::dot(wiW, bit), glm::dot(wiW, nor));

    glm::vec3 energy(0.f);
    for (int i = 0; i < bxdfs.size(); i++) {
        if ((bxdfs[i]->type & flags) == bxdfs[i]->type) {
            energy += bxdfs[i]->EvaluateScatteredEnergy(woW, wiW);
        }
    }

    return base_color * isx.texture_color * energy;
}
Ejemplo n.º 26
0
TEST(podio, Clearing){
  bool success = true;
  auto store = podio::EventStore();
  auto& hits  = store.create<ExampleHitCollection>("hits");
  auto& clusters  = store.create<ExampleClusterCollection>("clusters");
  auto nevents = unsigned(1000);
  for(unsigned i=0; i<nevents; ++i){
    hits.clear();
    clusters.clear();
    auto hit1 = hits.create();
    hit1.energy(double(i));
    auto hit2 = hits.create();
    auto cluster  = clusters.create();
    cluster.addHits(hit1);
  }
  hits.clear();
  if (hits.size() != 0 ) success = false;
  EXPECT_EQ(true, success);
}
Ejemplo n.º 27
0
/*!
 * This is the objective function for objects that have a cnls-like form
 * n coupled waves where the best solution is for each one to be a pulse.
 * It takes the energy of each pulse, and divides by the kurtosis of the
 * waveform of the laser pulse. This optimizes for energetic yet stable pulses
 */
double n_pulse_score::score(comp* ucur){
    //This is not an optimal solution,
    //but isn't too slow and this code should never be a bottleneck
    //This verison is far easier to read/understand than the optimal version
    for(size_t i = 0; i < nts; i++){
        help[i] = _sqabs(ucur[i]);
        for(size_t j = 1; j < n_pulse; j++){
            help[i] += _sqabs(ucur[i+j*nts]);
        }
        help[i] = sqrt(help[i]);
        kurtosis_help[i] = help[i];
    }
    double ener = energy(help, nts);
    fft(kurtosis_help, kurtosis_help, nts);
    for(size_t i = 0; i < nts; i++){
        help[i] = abs(kurtosis_help[i]);
    }
    double kurtosis_v = 1.0/(kurtosis(help, nts));
    double score = kurtosis_v* ener;
    return score;
}
Ejemplo n.º 28
0
    void CPDNRigid<Scalar, Dim>::compute()
    {
        size_t iter_num = 0;
        Scalar e_tol = 10 + this->e_tol_;
        Scalar e = 0;
        
        this->normalize();
        initialization();

        /*if (this->_vision)
        {
        RenderThread<Scalar, Dim>::instance()->updateModel(this->model_);
        RenderThread<Scalar, Dim>::instance()->updateData(this->data_);
        RenderThread<Scalar, Dim>::instance()->startThread();
        }*/

        while (iter_num < this->iter_num_ && e_tol > this->e_tol_ && paras_.sigma2_ > 10 * this->v_tol_)
        {

            e_step();
            
            Scalar old_e = e;
            e = energy();
            e += paras_.lambda_/2 * (paras_.W_.transpose()*G_*paras_.W_).trace();
            e_tol = fabs((e - old_e) / e);

            m_step();

            /*if (this->_vision == true)
            RenderThread<Scalar, Dim>::instance()->updateModel(this->T_);*/

            iter_num ++;
        }
        
        correspondences();
        this->updateModel();
        this->denormalize();
        this->rewriteOriginalSource();
        /*RenderThread<Scalar, Dim>::instance()->cancel();*/
    }
Ejemplo n.º 29
0
int main()
{
	double totald=0;
	//position *p=(position*) malloc(10 * sizeof(position));
	Z=79;
	double Ec=10000;
	A=117;
	srand(time(NULL));
	for (int i=0;i<10;i++)
	{
		energy(Ec);
		//printf("%f\n",E);
		//now for the interaction point
		//printf("%f\n",step());
		//printf("%f",phi());
		printf("step here is %f\n",step());
		printf("scattering angle here is %f\n",acos(cospsi()));
		printf("energy loss is %f\n",totalenergyloss());
	}
	
	return 0;
}
Ejemplo n.º 30
0
    void CPDNRigid<T, D>::run()
    {
        size_t iter_num = 0;
        T e_tol = 10 + _e_tol;
        T e = 0;
        
        normalize();
        initialization();

        if (_vision)
        {
            RenderThread<T, D>::instance()->updateModel(_model);
            RenderThread<T, D>::instance()->updateData(_data);
            RenderThread<T, D>::instance()->startThread();
        }

        while (iter_num < _iter_num && e_tol > _e_tol && _paras._sigma2 > 10 * _v_tol)
        {

            e_step();
            
            T old_e = e;
            e = energy();
            e += _paras._lambda/2 * (_paras._W.transpose()*_G*_paras._W).trace();
            e_tol = abs((e - old_e) / e);

            m_step();

            if (_vision == true)
                RenderThread<T, D>::instance()->updateModel(_T);

            iter_num ++;	
        }
        
        correspondences();
        updateModel();
        denormalize();
        RenderThread<T, D>::instance()->cancel();	
    }