コード例 #1
0
ファイル: matern.cpp プロジェクト: StochasticNumerics/mimclib
double Integrate(Vec U, int *pt, unsigned int i, myCSField sf) {
    if (i < sf->d){
        double g = 0;
        // Trapezoidal rule: \int_0^1 f(x) = (h/2) * \sum_{i=0}^{m} (f(x_i)+f(x_{i+1}))
        // In the special case where f(0) = f(1) = f(x_0) = f(x_{m+1}) = 0
        // \int_0^1 f(x) = 0.5*f(x_1) + {  \sum_{i=1}^{m-1} 0.5*(f(x_i)+f(x_{i+1}))  } + 0.5*f(x_m)
        double h_2 = (dx(i, sf)/2.);

        // u(x_0) = 0
        pt[i] = 1;
        g += Integrate(U, pt, i+1, sf) * h_2;
        for (pt[i]=1;pt[i]<sf->mesh[i];pt[i]++) {
            g += Integrate(U, pt, i+1, sf) * h_2;
            pt[i] += 1;
            g += Integrate(U, pt, i+1, sf) * h_2;
            pt[i] -= 1;
        }
        pt[i] = sf->mesh[i];
        g += Integrate(U, pt, i+1, sf) * h_2;
        // u(x_{m+1}) = 0
        return g;
    }
    int r = linIdx_Sys(sf->d, sf->mesh, pt,0,0);
    double x[sf->d];
    double Ux;
    getPoint(pt, x, sf);
    VecGetValues(U,1,&r,&Ux);
    return QoIAtPoint(x, Ux, sf);
}
コード例 #2
0
ファイル: FGPropagate.cpp プロジェクト: ToninoTarsi/jsbsim
bool FGPropagate::Run(bool Holding)
{
  if (FGModel::Run(Holding)) return true;  // Fast return if we have nothing to do ...
  if (Holding) return false;

  double dt = in.DeltaT * rate;  // The 'stepsize'

  // Propagate rotational / translational velocity, angular /translational position, respectively.

  Integrate(VState.qAttitudeECI,      in.vQtrndot,          VState.dqQtrndot,          dt, integrator_rotational_position);
  Integrate(VState.vPQRi,             in.vPQRidot,          VState.dqPQRidot,          dt, integrator_rotational_rate);
  Integrate(VState.vInertialPosition, VState.vInertialVelocity, VState.dqInertialVelocity, dt, integrator_translational_position);
  Integrate(VState.vInertialVelocity, in.vUVWidot,          VState.dqUVWidot,          dt, integrator_translational_rate);

  // CAUTION : the order of the operations below is very important to get transformation
  // matrices that are consistent with the new state of the vehicle

  // 1. Update the Earth position angle (EPA)
  VState.vLocation.IncrementEarthPositionAngle(in.vOmegaPlanet(eZ)*(in.DeltaT*rate));

  // 2. Update the Ti2ec and Tec2i transforms from the updated EPA
  Ti2ec = VState.vLocation.GetTi2ec(); // ECI to ECEF transform
  Tec2i = Ti2ec.Transposed();          // ECEF to ECI frame transform

  // 3. Update the location from the updated Ti2ec and inertial position
  VState.vLocation = Ti2ec*VState.vInertialPosition;

  // 4. Update the other "Location-based" transformation matrices from the updated
  //    vLocation vector.
  UpdateLocationMatrices();

  // 5. Update the "Orientation-based" transformation matrices from the updated
  //    orientation quaternion and vLocation vector.
  UpdateBodyMatrices();

  // Translational position derivative (velocities are integrated in the inertial frame)
  CalculateUVW();

  // Set auxilliary state variables
  RecomputeLocalTerrainVelocity();
  VehicleRadius = GetRadius(); // Calculate current aircraft radius from center of planet

  VState.vPQR = VState.vPQRi - Ti2b * in.vOmegaPlanet;

  VState.qAttitudeLocal = Tl2b.GetQuaternion();

  // Compute vehicle velocity wrt ECEF frame, expressed in Local horizontal frame.
  vVel = Tb2l * VState.vUVW;

  Debug(2);
  return false;
}
コード例 #3
0
ファイル: C3DBody.cpp プロジェクト: ttrask/staubliserver
//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
void C3DBody::Simulate( float fDeltaT )
{
	float fCurrentT = 0.0f;
#define FIXED_TIMESTEP 1
#if FIXED_TIMESTEP
	fDeltaT = 0.01f;
#endif
	
	float fEndT = fDeltaT;

	while( fCurrentT < fDeltaT )
	{
		SumForces();

		Integrate( fEndT - fCurrentT );

/*
		CalculateVertices(TargetConfigurationIndex);

		CheckForCollisions(TargetConfigurationIndex);

		if( CollisionState == Penetrating )
		{
			// we simulated too far, so subdivide time and try again
			fEndT = ( fCurrentT + fEndT ) * 0.5f;

			// blow up if we aren't moving forward each step, which is
			// probably caused by interpenetration at the frame start

			assert(fabs(TargetTime - CurrentTime) > Epsilon);
		}
		else
		{
			// either colliding or clear

		if( CollisionState == Colliding )
		{
			// @todo handle multiple simultaneous collisions

			int Counter = 0;
			do
			{
				ResolveCollisions(TargetConfigurationIndex);
				Counter++;
			}
			while((CheckForCollisions(TargetConfigurationIndex) == Colliding) && (Counter < 100));

			assert(Counter < 100);
			}
*/

		// we made a successful step, so swap configurations for the next step
		fCurrentT = fEndT;
		fEndT = fDeltaT;

		SwapStates();

//		}
	}
}
コード例 #4
0
ファイル: Suave.c プロジェクト: Bhattiasif/exciting
Extern void EXPORT(Suave)(ccount ndim, ccount ncomp,
  Integrand integrand, void *userdata,
  creal epsrel, creal epsabs,
  cint flags, cint seed,
  cnumber mineval, cnumber maxeval,
  cnumber nnew, creal flatness,
  cchar *statefile,
  count *pnregions, number *pneval, int *pfail,
  real *integral, real *error, real *prob)
{
  This t;
  t.ndim = ndim;
  t.ncomp = ncomp;
  t.integrand = integrand;
  t.userdata = userdata;
  t.epsrel = epsrel;
  t.epsabs = epsabs;
  t.flags = flags;
  t.seed = seed;
  t.mineval = mineval;
  t.maxeval = maxeval;
  t.nnew = nnew;
  t.flatness = flatness;
  t.statefile = statefile;

  *pfail = Integrate(&t, integral, error, prob);
  *pnregions = t.nregions;
  *pneval = t.neval;
}
コード例 #5
0
ファイル: matern.cpp プロジェクト: StochasticNumerics/mimclib
double SFieldSolveFor(SField sfv, double *Y, unsigned int yCount) {
    mySField sf = static_cast<mySField>(sfv);
    assert(yCount <= sf->maxN);
    assert(Y);
    assert(sf->running);
    sf->Y = Y;
    sf->curN = yCount;

    // -------------- SOLVE
    PetscErrorCode ierr;
    PetscLogDouble tic,toc;
    PetscTime(&tic);
    int pt[sf->d];

    ierr = MatZeroEntries(sf->J); CHKERRQ(ierr);
    JacobianOnD(sf->J, sf->F, 0, pt, sf);

    ierr = MatAssemblyBegin(sf->J,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
    ierr = MatAssemblyEnd(sf->J,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);

    PetscTime(&toc);
    sf->timeAssembly += toc-tic;
    PetscTime(&tic);
    ierr = VecZeroEntries(sf->U);  CHKERRQ(ierr);
    ierr = KSPSetOperators(sf->ksp, sf->J, sf->J); CHKERRQ(ierr);
    ierr = KSPSetUp(sf->ksp);  CHKERRQ(ierr);
    ierr = KSPSolve(sf->ksp,sf->F,sf->U); CHKERRQ(ierr);
    PetscTime(&toc);
    sf->timeSolver  += toc-tic;
    return Integrate(sf->U,pt,0,sf);
}
コード例 #6
0
ファイル: Grid.cpp プロジェクト: rrti/chandra
void Grid::SetForcedFirstScatterPos(Photon& p, const RNG& rng) const {
	cfloat tEdgeMax  = GetMaxOpticalDepth(p);
	cfloat photonWgt = 1.0f - expf(-tEdgeMax);
	cfloat tRunMax   = -logf(1.0f - (rng.FUniformRandom() * photonWgt));

	Integrate(p, tRunMax, IM_FORCED);
}
コード例 #7
0
Extern void EXPORT(Cuhre)(ccount ndim, ccount ncomp,
  Integrand integrand, void *userdata,
  creal epsrel, creal epsabs,
  cint flags, cnumber mineval, cnumber maxeval,
  ccount key,
  count *pnregions, number *pneval, int *pfail,
  real *integral, real *error, real *prob)
{
  This t;
  t.ndim = ndim;
  t.ncomp = ncomp;
  t.integrand = integrand;
  t.userdata = userdata;
  t.epsrel = epsrel;
  t.epsabs = epsabs;
  t.flags = flags;
  t.mineval = mineval;
  t.maxeval = maxeval;
  t.key = key;
  t.nregions = 0;
  t.neval = 0;
 
  *pfail = Integrate(&t, integral, error, prob);
  *pnregions = t.nregions;
  *pneval = t.neval;
}
コード例 #8
0
ファイル: Vegas.c プロジェクト: Bhattiasif/exciting
Extern void EXPORT(vegas)(ccount *pndim, ccount *pncomp,
  Integrand integrand, void *userdata,
  creal *pepsrel, creal *pepsabs, cint *pflags, cint *pseed,
  cnumber *pmineval, cnumber *pmaxeval,
  cnumber *pnstart, cnumber *pnincrease, 
  cnumber *pnbatch, cint *pgridno, cchar *statefile,
  number *pneval, int *pfail,
  real *integral, real *error, real *prob, cint statefilelen)
{
  This t;
  t.ndim = *pndim;
  t.ncomp = *pncomp;
  t.integrand = integrand;
  t.userdata = userdata;
  t.epsrel = *pepsrel;
  t.epsabs = *pepsabs;
  t.flags = *pflags;
  t.seed = *pseed;
  t.mineval = *pmineval;
  t.maxeval = *pmaxeval;
  t.nstart = *pnstart;
  t.nincrease = *pnincrease;
  t.nbatch = *pnbatch;
  t.gridno = *pgridno;
  t.statefile = CString(statefile, statefilelen);

  *pfail = Integrate(&t, integral, error, prob);
  *pneval = t.neval;
}
コード例 #9
0
ファイル: signalproc.cpp プロジェクト: amrsobhy/qminer
double TTDigest::MergeCentroid(double& Sum, double& K1, double& Wt, double& Ut) {
	double K2 = Integrate((double)Nc, Sum/TotalSum);
	if (K2 - K1 <= 1.0 || MergeWeight[Last] == 0.0) {
		// merge into existing centroid if centroid index difference (k2-k1)
		// is within 1 or if current centroid is empty
		MergeWeight[Last] += Wt;
		MergeMean[Last] += (Ut - MergeMean[Last]) * Wt / MergeWeight[Last];
	} else {
		// otherwise create a new centroid
		Last = ++Last;
		MergeMean[Last] = Ut;
		MergeWeight[Last] = Wt;
		K1 = Integrate((double)Nc, (Sum - Wt)/TotalSum);
	}
	return K1;
};
コード例 #10
0
ファイル: vegas.c プロジェクト: lazopolis/ehixs
Extern void EXPORT(Vegas)(ccount ndim, ccount ncomp,
  Integrand integrand, void *userdata,
  creal epsrel, creal epsabs, cint flags, cint seed,
  cnumber mineval, cnumber maxeval,
  cnumber nstart, cnumber nincrease, cnumber nbatch,
  cint gridno, cchar *statefile,
  number *pneval, int *pfail,
  real *integral, real *error, real *prob)
{
  This t;
  t.ndim = ndim;
  t.ncomp = ncomp;
  t.integrand = integrand;
  t.userdata = userdata;
  t.epsrel = epsrel;
  t.epsabs = epsabs;
  t.flags = flags;
  t.seed = seed;
  t.mineval = mineval;
  t.maxeval = maxeval;
  t.nstart = nstart;
  t.nincrease = nincrease;
  t.nbatch = nbatch;
  t.gridno = gridno;
  t.statefile = statefile;
  t.neval = 0;

  *pfail = Integrate(&t, integral, error, prob);
  *pneval = t.neval;
}
コード例 #11
0
Extern void EXPORT(suave)(ccount *pndim, ccount *pncomp,
  Integrand integrand, void *userdata,
  creal *pepsrel, creal *pepsabs,
  cint *pflags, cint *pseed,
  cnumber *pmineval, cnumber *pmaxeval,
  cnumber *pnnew, creal *pflatness,
  count *pnregions, number *pneval, int *pfail,
  real *integral, real *error, real *prob)
{
  This t;
  t.ndim = *pndim;
  t.ncomp = *pncomp;
  t.integrand = integrand;
  t.userdata = userdata;
  t.epsrel = *pepsrel;
  t.epsabs = *pepsabs;
  t.flags = *pflags;
  t.seed = *pseed;
  t.mineval = *pmineval;
  t.maxeval = *pmaxeval;
  t.nnew = *pnnew;
  t.flatness = *pflatness;
  t.nregions = 0;
  t.neval = 0;

  *pfail = Integrate(&t, integral, error, prob);
  *pnregions = t.nregions;
  *pneval = t.neval;
}
コード例 #12
0
	void BodyComponent::Update(double dt)
	{
		if (this->composition->getType() == GameObjects::PROJECTILE && this->composition->getProjectileType() == GameObjects::PUNCH) {
			if (!this->parentObject)
				return;
			int parentPosX = parentObject->getX();
			int parentPosY = parentObject->getY();

			int centerX = (parentPosX + (this->parentObject->getWidth() / 2));
			int centerY = (parentPosY + (this->parentObject->getHeight() / 2));
			GameComponents::SpriteComponent *sprite = reinterpret_cast<GameComponents::SpriteComponent*>(this->parentObject->getComponent(GameComponents::SPRITE));

			glm::vec2 direction = glm::vec2(100.0, 100.0);
			if (sprite->revertX) direction = glm::vec2((-100 + centerX) - centerX, (centerY)-centerY);
			else direction = glm::vec2((100 + centerX) - centerX, (centerY)-centerY);

			if (direction.x <= 0)
				this->getComposition()->setX(parentPosX - (this->parentObject->getWidth() / 2));
			else if (direction.x > 0)
				this->getComposition()->setX(parentPosX + (this->parentObject->getWidth() / 2) + 5);
			this->getComposition()->setY(parentPosY + (this->parentObject->getHeight() / 2) - 15);
		}
		else if (this->composition->getType() == GameObjects::PROJECTILE && this->composition->getProjectileType() == GameObjects::BOXER_POWERUP_AURA) {
			if (!this->parentObject)
				return;
			int parentPosX = parentObject->getX();
			int parentPosY = parentObject->getY();

			this->getComposition()->setX(parentPosX);
			this->getComposition()->setY(parentPosY);
		}
		else
			Integrate((float)(dt / 100));
	}
コード例 #13
0
ファイル: tube.cpp プロジェクト: amdj/timedomainresonance
void Tube::DoIntegration(d dt, int maxnr) {
  TRACE(14, "Tube::DoIntegration()");
  int intnr = 0;
  for (intnr=0; intnr < maxnr; intnr++) {
    sol=Integrate(dt);		// Update solution  
  }
}
コード例 #14
0
ファイル: Cuhre.c プロジェクト: ip1981/libcuba-debian
Extern void EXPORT(cuhre)(ccount *pndim, ccount *pncomp,
  Integrand integrand, void *userdata,
  creal *pepsrel, creal *pepsabs,
  cint *pflags, cnumber *pmineval, cnumber *pmaxeval,
  ccount *pkey,
  count *pnregions, number *pneval, int *pfail,
  real *integral, real *error, real *prob)
{
  This t;
  t.ndim = *pndim;
  t.ncomp = *pncomp;
  t.integrand = integrand;
  t.userdata = userdata;
  t.epsrel = *pepsrel;
  t.epsabs = *pepsabs;
  t.flags = *pflags;
  t.mineval = *pmineval;
  t.maxeval = *pmaxeval;
  t.key = *pkey;
  t.nregions = 0;
  t.neval = 0;
 
  ForkCores(&t);

  *pfail = Integrate(&t, integral, error, prob);
  *pnregions = t.nregions;
  *pneval = t.neval;

  WaitCores(&t);
}
コード例 #15
0
ファイル: Systems.cpp プロジェクト: Azurelol/Samples
 void PhysicsSystem::Step(float dt) {
   SystemMethodTimer(__FUNCTION__, Enumerated::Physics);
   Integrate();
   BroadPhaseDetection();
   NarrowPhaseDetection();
   Resolve();
   Publish();
 }
コード例 #16
0
void
AxisPhysicsModel::Simulate(const TimeDuration& aDeltaTime)
{
  for(mProgress += aDeltaTime.ToSeconds() / kFixedTimestep;
      mProgress > 1.0; mProgress -= 1.0) {
    Integrate(kFixedTimestep);
  }
}
コード例 #17
0
ファイル: Divonne.c プロジェクト: jonaslindert/susyhell
Extern void EXPORT(Divonne)(ccount ndim, ccount ncomp,
  Integrand integrand,
  creal epsrel, creal epsabs,
  cint flags, cnumber mineval, cnumber maxeval,
  cint key1, cint key2, cint key3, ccount maxpass,
  creal border, creal maxchisq, creal mindeviation,
  cnumber ngiven, ccount ldxgiven, real *xgiven,
  cnumber nextra, PeakFinder peakfinder,
  int *pnregions, number *pneval, int *pfail,
  real *integral, real *error, real *prob)
{
  ndim_ = ndim;
  ncomp_ = ncomp;

  if( BadComponent(ncomp) ||
      BadDimension(ndim, flags, key1) ||
      BadDimension(ndim, flags, key2) ||
      ((key3 & -2) && BadDimension(ndim, flags, key3)) ) *pfail = -1;
  else {
    neval_ = neval_opt_ = neval_cut_ = 0;
    integrand_ = integrand;
    peakfinder_ = peakfinder;
    border_.lower = border;
    border_.upper = 1 - border_.lower;
    ngiven_ = ngiven;
    xgiven_ = NULL;
    ldxgiven_ = IMax(ldxgiven, ndim_);
    nextra_ = nextra;

    if( ngiven + nextra ) {
      cnumber nxgiven = ngiven*ldxgiven;
      cnumber nxextra = nextra*ldxgiven;
      cnumber nfgiven = ngiven*ncomp;
      cnumber nfextra = nextra*ncomp;

      Alloc(xgiven_, nxgiven + nxextra + nfgiven + nfextra);
      xextra_ = xgiven_ + nxgiven;
      fgiven_ = xextra_ + nxextra;
      fextra_ = fgiven_ + nfgiven;

      if( nxgiven ) {
        phase_ = 0;
        Copy(xgiven_, xgiven, nxgiven);
        DoSample(ngiven_, ldxgiven_, xgiven_, fgiven_);
      }
    }

    *pfail = Integrate(epsrel, Max(epsabs, NOTZERO),
      flags, mineval, maxeval, key1, key2, key3, maxpass,
      maxchisq, mindeviation,
      integral, error, prob);
    *pnregions = nregions_;
    *pneval = neval_;

    if( xgiven_ ) free(xgiven_);
  }
}
コード例 #18
0
bool ExponentialPoint(const Vector3 &p, double lambda, 
        double divisor, const Vector3 &v0, const Vector3 &v1, 
        const Vector3 &v2, BBox3 &box, Vector3 *v)
{
    Rank rank(p, lambda, divisor);
    Integrate(v0, v1, v2, box, rank, divisor*divisor/25);
    rank.Done();
    return rank.Sample(v);
}
コード例 #19
0
/**
* Moves the object
*
**/
void Movable::Update(float dt)
{
	m_vPosition = m_rParent.GetPosition();
	m_fRotation = m_rParent.GetRotation();

	Integrate(dt);

	m_rParent.SetPosition(m_vPosition);
	m_rParent.SetRotation(m_fRotation);
}
コード例 #20
0
void PhysicsSystem::Update(float deltaTime)
{
    Integrate(deltaTime);
    DetectCollisions();
    ResolveContacts(deltaTime);
    SendCollisionMessages();

    contacts.clear();
    UpdateDebugDraw();
}
コード例 #21
0
ファイル: PhysicsWorld.cpp プロジェクト: Khillasaurus/School
void PhysicsWorld::StepSimulation(f32 deltaTime)
{
	mTimer += deltaTime;
	if (mTimer >= mSettings.timeStep)
	{
		mTimer -= mSettings.timeStep;
		AccumulateForces();
		Integrate();
		SatisfyConstraints();
	}
}
コード例 #22
0
ファイル: Divonne.c プロジェクト: leloulight/micro_omega_4
void Divonne(ccount ndim, ccount ncomp, Integrand integrand,
             creal epsrel, creal epsabs,
             cint flags, ccount mineval, ccount maxeval,
             cint key1, cint key2, cint key3, ccount maxpass,
             creal border, creal maxchisq, creal mindeviation,
             ccount ngiven, ccount ldxgiven, real *xgiven,
             ccount nextra, PeakFinder peakfinder,
             int *pnregions, int *pneval, int *pfail,
             real *integral, real *error, real *prob)
{
    ndim_ = ndim;
    ncomp_ = ncomp;

    if( ndim < MINDIM || ndim > MAXDIM ) *pfail = -1;
    else {
        neval_ = neval_opt_ = neval_cut_ = 0;
        integrand_ = integrand;
        peakfinder_ = peakfinder;
        border_.lower = border;
        border_.upper = 1 - border_.lower;
        ngiven_ = ngiven;
        xgiven_ = NULL;
        ldxgiven_ = IMax(ldxgiven, ndim_);
        nextra_ = nextra;

        if( ngiven + nextra ) {
            ccount nxgiven = ngiven*ldxgiven;
            ccount nxextra = nextra*ldxgiven;
            ccount nfgiven = ngiven*ncomp;
            ccount nfextra = nextra*ncomp;

            Allocate(xgiven_, nxgiven + nxextra + nfgiven + nfextra);
            xextra_ = xgiven_ + nxgiven;
            fgiven_ = xextra_ + nxextra;
            fextra_ = fgiven_ + nfgiven;

            if( nxgiven ) {
                phase_ = 0;
                Copy(xgiven_, xgiven, nxgiven);
                DoSample(ngiven_, ldxgiven_, xgiven_, fgiven_);
            }
        }

        *pfail = Integrate(epsrel, Max(epsabs, NOTZERO),
                           flags, mineval, maxeval, key1, key2, key3, maxpass,
                           maxchisq, mindeviation,
                           integral, error, prob);
        *pnregions = nregions_;
        *pneval = neval_;

        if( xgiven_ ) free(xgiven_);
    }
}
コード例 #23
0
ファイル: SimObject.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ SimObject::Update()
//-------------------------------------------------------------------------------
// Update object
//-------------------------------------------------------------------------------
void
SimObject::Update( float dt )
{
    Integrate( dt );

    // recompute world segment location
    mWorldCapsule = mLocalCapsule.Transform( 1.0f, mRotate, mTranslate );

    float radius = mWorldCapsule.GetRadius();
    ASSERT( radius > 0.0f );

}   // End of SimObject::Update()
コード例 #24
0
/*-----------------------------------------------------------------------------*/
int GridIntegrate(size_t const ncells, float conc[], float const tstart,
    float const tend, float const  abstol[NVAR], float const  reltol[NVAR],
    int idata[20], float rdata[20], float lastH[/* ncells */])
{
    /* Return value */
    int retval = 0;
    /* Iterators */
    int i, j;
    /* Pointer to variable concentrations in grid cell */
    float * var;
    /* Pointer to fixed concentrations in grid cell */
    float * fix;

    #pragma omp parallel for \
                default(shared) \
                private(i,j,var,fix) \
                firstprivate(idata, rdata) \
                lastprivate(idata, rdata) \
                reduction(|:retval)
    for(i=0; i<ncells; ++i) {
        /* Get concentrations for the current grid cell */
        var = conc + i*NSPEC;
        fix = var + NVAR;

        /* Invoke the integrator */
        Integrate(var, fix, i, tstart, tend, abstol, reltol, idata, rdata);

        /* Save the last timestep for future use */
        if(lastH) {
            lastH[i] = rdata[11];
        }

        /* Process integrator return code */
        if (idata[19] < 0) {
            printf("Kppa: CELL %d -- INTEGRATION FAILED\n", i);
            #pragma omp critical
            {
                for(j=0; j<20; ++j)
                    printf("Kppa: CELL %d -- idata[%d] = %d\n", i, j, idata[j]);
                for(j=0; j<20; ++j)
                    printf("Kppa: CELL %d -- rdata[%d] = %g\n", i, j, rdata[j]);
            }
            if (idata[19] < retval)
                retval = idata[19];
        } else if (idata[19] > 0) {
            printf("Kppa: CELL %d -- INTEGRATION COMPLETED WITH WARNING\n", i);
            if (retval >= 0 && idata[19] > retval)
                retval = idata[19];
        }
    }
    
    return retval;
}/* END GridIntegrate */
コード例 #25
0
ファイル: World.cpp プロジェクト: wrdn/2DPhysics
void World::IntegrateBoxForces(f64 dt)
{
	/*integration_data.clear();
	int numPerThread = 100; // should be a multiple of 1,2,5,10,20,25,50,100,200 or 400
	for(int i=0;i<firstTriangleIndex-4;i+=numPerThread) // 0 to 800
	{
	IntegrationData idt(i, i+numPerThread, dt, this);
	integration_data.push_back(idt);
	physicsPool->AddTask(Task(TAddForces, &integration_data.back()));
	}*/
	IntegrationData idt(0, firstTriangleIndex, dt, this);
	Integrate(&idt);
	//physicsPool->FinishAllTasks();
};
コード例 #26
0
ファイル: statistics.cpp プロジェクト: joeedh/psa
static void RDFtoRP(const Curve &rdf, int npoints, Curve *rp) {
    const float wstep = 1.f / sqrtf(npoints);
    Curve tmp(rdf);
    for (int i = 0; i < rp->size(); ++i) {
        const float u0 = rp->ToX(i);
        const float u = TWOPI * u0;
        const float wndsize = rdf.x1 * std::min(0.5f, std::max(0.2f, 4.f * u0 * wstep));
        for (int j = 0; j < tmp.size(); ++j) {
            float x = rdf.ToX(j);
            float wnd = BlackmanWindow(x, wndsize);
            tmp[j] = (rdf[j] - 1) * j0f(u*x) * x * wnd;
        }
        (*rp)[i] = fabsf(1.f + TWOPI * Integrate(tmp) * npoints);
    }
}
コード例 #27
0
ファイル: vb7.c プロジェクト: kwrobert/ResearchCode
int main ()
 { Point A(0,0), B(1.107148717794090503,0);
   SEMI_INFINITE_STRIP langelat(A,B);

   EvaluationCounter TikTak; TikTak.Start();
 //  cout.setf(ios::left,ios::adjustfield);
   cout.setf(ios::scientific,ios::floatfield);

   cout <<"The integral is " << Integrate(f,langelat,0,0.5e-4,10000);
   cout <<" with estimated absolute error "
        << langelat.AbsoluteError() << endl;

   TikTak.Stop(); cout<<"Number of evaluations = "<<TikTak.Read()<<endl;

   return 0;
 }
コード例 #28
0
Extern void EXPORT(Divonne)(ccount ndim, ccount ncomp,
  Integrand integrand, void *userdata,
  creal epsrel, creal epsabs,
  cint flags, cint seed,
  cnumber mineval, cnumber maxeval,
  cint key1, cint key2, cint key3, ccount maxpass,
  creal border, creal maxchisq, creal mindeviation,
  cnumber ngiven, ccount ldxgiven, creal *xgiven,
  cnumber nextra, PeakFinder peakfinder,
  int *pnregions, number *pneval, int *pfail,
  real *integral, real *error, real *prob)
{
  This t;
  t.ndim = ndim;
  t.ncomp = ncomp;
  t.integrand = integrand;
  t.userdata = userdata;
  t.epsrel = epsrel;
  t.epsabs = epsabs;
  t.flags = flags;
  t.seed = seed;
  t.mineval = mineval;
  t.maxeval = maxeval;
  t.key1 = key1;
  t.key2 = key2;
  t.key3 = key3;
  t.maxpass = maxpass;
  t.border.upper = 1 - (t.border.lower = border);
  t.maxchisq = maxchisq;
  t.mindeviation = mindeviation;
  t.ngiven = ngiven;
  t.xgiven = NULL;
  t.ldxgiven = ldxgiven;
  t.nextra = nextra;
  t.peakfinder = peakfinder;
  t.nregions = 0;
  t.neval = 0;

  AllocGiven(&t, xgiven);

  *pfail = Integrate(&t, integral, error, prob);
  *pnregions = t.nregions;
  *pneval = t.neval;

  free(t.xgiven);
}
コード例 #29
0
ファイル: cmodel.cpp プロジェクト: Sophiealex/jgt-code
void CModel::FacetHarmonics(int fh, int bw, double r, gsl_complex *coeff){
  int i, j, sign;
  gsl_complex err;
  
  Triangle_3 tr;
  tr = Triangle_3(plist[flist[fh*3+0]],plist[flist[fh*3+1]],plist[flist[fh*3+2]]);
  Tetrahedron_3 tetr;
  tetr = Tetrahedron_3(Point_3(0.0, 0.0, 0.0),plist[flist[fh*3+0]],plist[flist[fh*3+1]],plist[flist[fh*3+2]]);
  if(tetr.is_degenerate()) return;
  sign = (tetr.volume()<0 ? -1 : 1);
  
  for(i=0; i<bw; i++){
    for(j=0; j<=i; j++){
      Integrate(i, j, r, tetr, &coeff[i*bw+j], &err);
      coeff[i*bw+j] = gsl_complex_mul_real(coeff[i*bw+j], (double)sign);
    }
  }
}
コード例 #30
0
ファイル: vegas.c プロジェクト: lazopolis/ehixs
Extern void EXPORT(vegas)(ccount *pndim, ccount *pncomp,
  Integrand integrand, void *userdata,
  creal *pepsrel, creal *pepsabs, cint *pflags, cint *pseed,
  cnumber *pmineval, cnumber *pmaxeval,
  cnumber *pnstart, cnumber *pnincrease, 
  cnumber *pnbatch, cint *pgridno, cchar *statefile,
  number *pneval, int *pfail,
  real *integral, real *error, real *prob, int statefilelen)
{
  char *s = NULL;
  This t;
  t.ndim = *pndim;
  t.ncomp = *pncomp;
  t.integrand = integrand;
  t.userdata = userdata;
  t.epsrel = *pepsrel;
  t.epsabs = *pepsabs;
  t.flags = *pflags;
  t.seed = *pseed;
  t.mineval = *pmineval;
  t.maxeval = *pmaxeval;
  t.nstart = *pnstart;
  t.nincrease = *pnincrease;
  t.nbatch = *pnbatch;
  t.gridno = *pgridno;
  t.neval = 0;

  if( statefile ) {
	/* strip trailing spaces */
    while( statefilelen > 0 && statefile[statefilelen - 1] == ' ' )
      --statefilelen;
    if( statefilelen > 0 && (s = malloc(statefilelen + 1)) ) {
      memcpy(s, statefile, statefilelen);
      s[statefilelen] = 0;
    }
  }
  t.statefile = s;

  *pfail = Integrate(&t, integral, error, prob);
  *pneval = t.neval;

  free(s);
}