コード例 #1
0
//The main fluid simulation step
void FluidSim::advance(float dt) {
   float t = 0;
   
   while(t < dt) {
      float substep = cfl();   
      if(t + substep > dt)
         substep = dt - t;
   
      //Passively advect particles
      advect_particles(substep);
     
      //Estimate the liquid signed distance
      compute_phi();

      //Advance the velocity
      advect(substep);
      add_force(substep);

      apply_viscosity(substep);

      apply_projection(substep); 
      
      //Pressure projection only produces valid velocities in faces with non-zero associated face area.
      //Because the advection step may interpolate from these invalid faces, 
      //we must extrapolate velocities from the fluid domain into these zero-area faces.
      extrapolate(u, u_valid);
      extrapolate(v, v_valid);

      //For extrapolated velocities, replace the normal component with
      //that of the object.
      constrain_velocity();
   
      t+=substep;
   }
}
コード例 #2
0
  Linear_function(const Point &p, FT fp, 
		  const Point &q, FT fq,
		  const Point &r, FT fr) 
  {
    _c = extrapolate(Point(0,0), p, fp, q, fq, r, fr); // const term
    _a = extrapolate(Point(1,0), p, fp, q, fq, r, fr) - _c;
    _b = extrapolate(Point(0,1), p, fp, q, fq, r, fr) - _c;
  }
コード例 #3
0
ファイル: extrapolater.c プロジェクト: John-He-928/fdkaac
static int process2(extrapolater_t *self, void *buffer, unsigned nframes)
{
    const pcm_sample_description_t *sfmt = pcm_get_format(self->src);
    buffer_t *bp = &self->buffer[self->nbuffer];
    buffer_t *bbp = &self->buffer[self->nbuffer ^ 1];

    if (bp->count < 2 * LPC_ORDER) {
        size_t total = bp->count + bbp->count;
        if (bbp->count &&
            realloc_buffer(bbp, total * sfmt->bytes_per_frame) == 0)
        {
            memcpy(bbp->data + bbp->count * sfmt->channels_per_frame,
                   bp->data, bp->count * sfmt->bytes_per_frame);
            bbp->count = total;
            bp->count = 0;
            bp = bbp;
            self->nbuffer ^= 1;
        }
    }
    self->process = process3;

    if (bp->count >= 2 * LPC_ORDER)
        extrapolate(self, bp, buffer, nframes);
    else
        memset(buffer, 0, nframes * sfmt->bytes_per_frame);
    return nframes;
}
コード例 #4
0
void rspfLandSatModel::lineSampleHeightToWorld(const rspfDpt& image_point,
                                                const double&   height,
                                                rspfGpt&       gpt) const
{
   if (traceExec())  rspfNotify(rspfNotifyLevel_DEBUG) << "DEBUG rspfLandSatModel::lineSampleHeightToWorld: entering..." << std::endl;
#if 0
   if (!insideImage(image_point))
   {
      gpt = extrapolate(image_point, height);
      if (traceExec())  rspfNotify(rspfNotifyLevel_DEBUG) << "DEBUG rspfLandSatModel::lineSampleHeightToWorld: returning..." << std::endl;
      return;
   }
#endif
   
   rspfEcefRay imaging_ray;
   imagingRay(image_point, imaging_ray);
   //rspfEcefPoint Pecf (imaging_ray.intersectAboveEarthEllipsoid(height));
   //gpt = rspfGpt(Pecf);
   if (m_proj==NULL)  {
	   rspfEcefPoint Pecf (imaging_ray.intersectAboveEarthEllipsoid(height));
		gpt = rspfGpt(Pecf);
   }
   else
   {
	   rspfEcefPoint Pecf (imaging_ray.intersectAboveEarthEllipsoid(height,m_proj->getDatum()));
   gpt = rspfGpt(Pecf,m_proj->getDatum());
   }

}
コード例 #5
0
ファイル: Entity.cpp プロジェクト: Jairard/Brotato
	void Entity::render(sf::RenderTarget& target, float coef, sf::RenderStates states)
	{
		UNUSED(target);
		UNUSED(states);
		
		extrapolate(coef);
	}
コード例 #6
0
void CoreAudioPaddedEncoder::extrapolate0()
{
    unsigned nchannels = getInputDescription().mChannelsPerFrame;
    unsigned bpf = getInputDescription().mBytesPerFrame;
    unsigned shift = (getOutputDescription().mFormatID == 'aach') ? 1 : 0;
    unsigned fpp = getOutputDescription().mFramesPerPacket;
    unsigned nsamples = fpp / 2;
    unsigned padding = (getOutputDescription().mFormatID == 'aac ')
        ? m_num_priming + 3 * fpp - APPLE_NUM_PRIMING - nsamples
        : nsamples;

    std::vector<float> buf(nsamples * nchannels);
    size_t n = readSamplesFull(src(), &buf[0], nsamples);
    m_buffer.reserve(nsamples + n + padding);
    if (padding > 0) {
        std::memset(m_buffer.write_ptr(), 0, padding * bpf);
        m_buffer.commit(padding);
    }
    if (n < 2 * LPC_ORDER)
        std::memset(m_buffer.write_ptr(), 0, nsamples * bpf);
    else {
        reverse_buffer(&buf[0], n, nchannels);
        extrapolate(&buf[0], n, m_buffer.write_ptr(), nsamples);
        reverse_buffer(m_buffer.write_ptr(), nsamples, nchannels);
        reverse_buffer(&buf[0], n, nchannels);
    }
    m_buffer.commit(nsamples);
    std::copy(buf.begin(), buf.begin() + n * nchannels,
              m_buffer.write_ptr());
    m_buffer.commit(n);
}
コード例 #7
0
ファイル: romberg.cpp プロジェクト: niklasfi/mapra2011
double Rom::integrate_wisely(double a, double b, double eps){	// Romberg mit Extrapolation
	extrapol[0]=stepInit();		// = T[0,0]
	
	print();			// Ausgabe	
	
	while(extrapolate() > eps);	// Fehler bis zum Epsilon abschaetzen mit Extrapolation
	
	return extrapol[index];		// Abschaetzung mit Epsilon genauigkeit
}
コード例 #8
0
//The main fluid simulation step
void FluidSim::advance(float dt) {
   
   //Passively advect particles
   advect_particles(dt);

   //Advance the velocity
   advect(dt);
   add_force(dt);
   project(dt); 
   
   //Pressure projection only produces valid velocities in faces with non-zero associated face area.
   //Because the advection step may interpolate from these invalid faces, 
   //we must extrapolate velocities from the fluid domain into these zero-area faces.
   extrapolate(u, u_weights, valid, old_valid);
   extrapolate(v, v_weights, valid, old_valid);
   
   //For extrapolated velocities, replace the normal component with
   //that of the object.
   constrain_velocity();
   
}
コード例 #9
0
void CoreAudioPaddedEncoder::extrapolate1()
{
    unsigned fpp = getOutputDescription().mFramesPerPacket;
    unsigned bpf = getInputDescription().mBytesPerFrame;
    size_t count = m_buffer.count();
    m_buffer.reserve(fpp);
    if (count >= 2 * LPC_ORDER)
        extrapolate(m_buffer.read_ptr(), count, m_buffer.write_ptr(), fpp);
    else
        std::memset(m_buffer.write_ptr(), 0, fpp * bpf);
    m_buffer.commit(fpp);
}
コード例 #10
0
ファイル: Bs_integrator.cpp プロジェクト: Ingwar/amuse
void Bs_integrator::extrapol( Cluster &cl_exp, vector<mpreal> &h, vector<Cluster> &cl )
{
  int M = h.size();
  int N = cl[0].get_N();

  vector< Star* > st(M);
  for(int i=0; i<M; i++) st[i] = cl[i].get_pointer_to_star();  
  Star* st_exp = cl_exp.get_pointer_to_star(); 

  for(int i=0; i<N; i++)
  {
    vector<mpreal> x_sample(M), y_sample(M), z_sample(M), vx_sample(M), vy_sample(M), vz_sample(M);

    for(int j=0; j<M; j++)
    {
      x_sample[j] = st[j]->x;
      y_sample[j] = st[j]->y;
      z_sample[j] = st[j]->z;
      vx_sample[j] = st[j]->vx;
      vy_sample[j] = st[j]->vy;
      vz_sample[j] = st[j]->vz;
    }

    st_exp->x = extrapolate(h, x_sample, "0.0");
    st_exp->y = extrapolate(h, y_sample, "0.0");
    st_exp->z = extrapolate(h, z_sample, "0.0");
    st_exp->vx = extrapolate(h, vx_sample, "0.0");
    st_exp->vy = extrapolate(h, vy_sample, "0.0");
    st_exp->vz = extrapolate(h, vz_sample, "0.0");

    for(int j=0; j<M; j++) st[j]++;   
    st_exp++; 
  }
}
コード例 #11
0
//The main fluid simulation step
void FluidSim::advance(float dt) {
   float t = 0;

   while(t < dt) {
      float substep = cfl();   
      if(t + substep > dt)
         substep = dt - t;
      printf("Taking substep of size %f (to %0.3f%% of the frame)\n", substep, 100 * (t+substep)/dt);
      
      printf(" Surface (particle) advection\n");
      advect_particles(substep);

      printf(" Velocity advection\n");
      //Advance the velocity
      advect(substep);
      add_force(substep);
      
      printf(" Solve viscosity");
      apply_viscosity(substep);

      printf(" Pressure projection\n");
      project(substep); 
       
      //Pressure projection only produces valid velocities in faces with non-zero associated face area.
      //Because the advection step may interpolate from these invalid faces, 
      //we must extrapolate velocities from the fluid domain into these invalid faces.
      printf(" Extrapolation\n");
      extrapolate(u, u_valid);
      extrapolate(v, v_valid);
      extrapolate(w, w_valid);
    
      //For extrapolated velocities, replace the normal component with
      //that of the object.
      printf(" Constrain boundary velocities\n");
      constrain_velocity();

      t+=substep;
   }
}
コード例 #12
0
ファイル: extrapolate.cpp プロジェクト: NVIDIA/Forma
int main() {
  double* inp1 = new double[M*N];
  double* outp = new double[3*M*2*N];
  double* outp_ref = new double[3*M*2*N];

  for( int i = 0 ; i < M ; i++ )
    for( int j = 0 ; j < N ; j++ )
      inp1[i*N+j] = (double)rand() / (double)RAND_MAX;
    
  for( int i = 0 ; i < 3*M ; i++ )
    for( int j = 0 ; j < 2*N ; j++ ){
      outp[i*2*N+j] = 0.0;
      outp_ref[i*2*N+j] = 0.0;
    }

  extrapolate(inp1,M,N,outp);
  ref_output(inp1,outp_ref);
  
  printf("Input[%d,%d] :\n",M,N);
  for( int i = 0 ; i < M ; i++ ){
    for( int j = 0 ; j < N ; j++ )
      printf(" %f",inp1[i*(N)+j]);
    printf("\n");
  }
  printf("Output[%d,%d] :\n",3*M,2*N);
  for( int i = 0 ; i < 3*M ; i++ ){
    for( int j = 0 ; j < 2*N ; j++ )
      printf(" %f",outp[i*(2*N)+j]);
    printf("\n");
  }
  printf("OutputRef[%d,%d] :\n",3*M,2*N);
  for( int i = 0 ; i < 3*M ; i++ ){
    for( int j = 0 ; j < 2*N ; j++ )
      printf(" %f",outp_ref[i*(2*N)+j]);
    printf("\n");
  }

  double diff = 0.0;
  for( int i = 0 ; i < 3*M ; i++) 
    for( int j = 0 ; j < 2*N ; j++ )
      diff += fabs(outp_ref[i*(2*N)+j] - outp[i*(2*N)+j]);
  printf("Diff : %f\n",diff);
  if( diff != 0.0) {
    printf("Incorrect Result\n");
    exit(1);
  }

  delete[] inp1;
  delete[] outp;
  delete[] outp_ref;
}
コード例 #13
0
ファイル: Vector.cpp プロジェクト: kralf/rotor-smartter
double 
Vector::radius( const Point & center ) const
{
  const Point & p1 = center;
  const Point & p2 = _origin;
  const Point & p3 = extrapolate( 1 )._origin;
  double sign =   ( p2[0] - p1[0] ) * ( p3[1] - p1[1] ) 
                - ( p2[1] - p1[1] ) * ( p3[0] - p1[0] );
  double r = distance( center );
  if ( sign >= 0 )
  {
    return r;
  } else {
    return -r;
  }
}
コード例 #14
0
 void do_step_impl( System system, const StateIn &in, const DerivIn &dxdt,
                    time_type t, StateOut &out, time_type dt )
 {
     m_resizer.adjust_size(
         in, detail::bind( &stepper_type::template resize_impl< StateIn >,
                           detail::ref( *this ), detail::_1 ) );
     size_t k = 0;
     m_midpoint.set_steps( m_interval_sequence[k] );
     m_midpoint.do_step( system, in, dxdt, t, out, dt );
     for ( k = 1; k <= m_k_max; ++k )
     {
         m_midpoint.set_steps( m_interval_sequence[k] );
         m_midpoint.do_step( system, in, dxdt, t, m_table[k - 1].m_v, dt );
         extrapolate( k, m_table, m_coeff, out );
     }
 }
コード例 #15
0
ファイル: extrapolater.c プロジェクト: John-He-928/fdkaac
static int process0(extrapolater_t *self, void *buffer, unsigned nframes)
{
    const pcm_sample_description_t *sfmt = pcm_get_format(self->src);
    unsigned nchannels = sfmt->channels_per_frame;
    buffer_t *bp = &self->buffer[self->nbuffer];

    if (fetch(self, nframes) < 2 * LPC_ORDER)
        memset(buffer, 0, nframes * sfmt->bytes_per_frame);
    else {
        reverse_buffer(bp->data, bp->count, nchannels);
        extrapolate(self, bp, buffer, nframes);
        reverse_buffer(buffer, nframes, nchannels);
        reverse_buffer(bp->data, bp->count, nchannels);
    }
    self->process = bp->count ? process1 : process2;
    return nframes;
}
コード例 #16
0
void rspfBuckeyeSensor::lineSampleHeightToWorld(const rspfDpt& image_point,
                                                 const double&   heightEllipsoid,
                                                 rspfGpt&       worldPoint) const
{
   if (!insideImage(image_point))
   {
      worldPoint.makeNan();
      worldPoint = extrapolate(image_point, heightEllipsoid);
   }
   else
   {
      rspfEcefRay ray;
      imagingRay(image_point, ray);
      rspfEcefPoint Pecf (ray.intersectAboveEarthEllipsoid(heightEllipsoid));
      worldPoint = rspfGpt(Pecf);
   }
   
}
コード例 #17
0
void extrapolate(index_t num_samples, index_t start_index,
        SequenceFunc f, mpf_t ans) {
    // Calculate the desired samples, then pass to the other extrapolate
    // function.
    mpf_t *samples = (mpf_t*)malloc(sizeof(mpf_t) * num_samples);
    mpf_t *lim = samples + num_samples;
    mp_bitcnt_t precision = mpf_get_prec(ans);
    for (mpf_t *ptr = samples; ptr < lim; ptr++, start_index <<= 1) {
        mpf_init2(*ptr, precision);
        f(start_index, *ptr);
    }
    extrapolate(num_samples, samples, ans);

    // Clean
    for (mpf_t *ptr = samples; ptr < lim; ptr++)
        mpf_clear(*ptr);
    free(samples);
}
コード例 #18
0
void ossimCsmSensorModel::lineSampleHeightToWorld(const ossimDpt& image_point,
                                                  const double&   heightEllipsoid,
                                                  ossimGpt&       worldPoint) const
{
   if (!insideImage(image_point))
   {
      worldPoint.makeNan();
      worldPoint = extrapolate(image_point, heightEllipsoid);
   }
   else
   {
      //***
      // First establish imaging ray from image point:
      //***
      ossimEcefRay ray;
      imagingRay(image_point, ray);
      ossimEcefPoint Pecf (ray.intersectAboveEarthEllipsoid(heightEllipsoid));
      worldPoint = ossimGpt(Pecf);
   }
   
}
コード例 #19
0
ファイル: simplex.cpp プロジェクト: cathie912jin/quantlib
    EndCriteria::Type Simplex::minimize(Problem& P,
                                        const EndCriteria& endCriteria) {
        // set up of the problem
        //Real ftol = endCriteria.functionEpsilon();    // end criteria on f(x) (see Numerical Recipes in C++, p.410)
        Real xtol = endCriteria.rootEpsilon();          // end criteria on x (see GSL v. 1.9, http://www.gnu.org/software/gsl/)
        Size maxStationaryStateIterations_
            = endCriteria.maxStationaryStateIterations();
        EndCriteria::Type ecType = EndCriteria::None;
        P.reset();
        Array x_ = P.currentValue();
        Integer iterationNumber_=0;

        // Initialize vertices of the simplex
        bool end = false;
        Size n = x_.size(), i;
        vertices_ = std::vector<Array>(n+1, x_);
        for (i=0; i<n; i++) {
            Array direction(n, 0.0);
            direction[i] = 1.0;
            P.constraint().update(vertices_[i+1], direction, lambda_);
        }
        // Initialize function values at the vertices of the simplex
        values_ = Array(n+1, 0.0);
        for (i=0; i<=n; i++)
            values_[i] = P.value(vertices_[i]);
        // Loop looking for minimum
        do {
            sum_ = Array(n, 0.0);
            Size i;
            for (i=0; i<=n; i++)
                sum_ += vertices_[i];
            // Determine the best (iLowest), worst (iHighest)
            // and 2nd worst (iNextHighest) vertices
            Size iLowest = 0;
            Size iHighest, iNextHighest;
            if (values_[0]<values_[1]) {
                iHighest = 1;
                iNextHighest = 0;
            } else {
                iHighest = 0;
                iNextHighest = 1;
            }
            for (i=1;i<=n; i++) {
                if (values_[i]>values_[iHighest]) {
                    iNextHighest = iHighest;
                    iHighest = i;
                } else {
                    if ((values_[i]>values_[iNextHighest]) && i!=iHighest)
                        iNextHighest = i;
                }
                if (values_[i]<values_[iLowest])
                    iLowest = i;
            }
            // Now compute accuracy, update iteration number and check end criteria
            //// Numerical Recipes exit strategy on fx (see NR in C++, p.410)
            //Real low = values_[iLowest];
            //Real high = values_[iHighest];
            //Real rtol = 2.0*std::fabs(high - low)/
            //    (std::fabs(high) + std::fabs(low) + QL_EPSILON);
            //++iterationNumber_;
            //if (rtol < ftol ||
            //    endCriteria.checkMaxIterations(iterationNumber_, ecType)) {
            // GSL exit strategy on x (see GSL v. 1.9, http://www.gnu.org/software/gsl
            Real simplexSize = computeSimplexSize(vertices_);
            ++iterationNumber_;
            if (simplexSize < xtol ||
                endCriteria.checkMaxIterations(iterationNumber_, ecType)) {
                endCriteria.checkStationaryPoint(0.0, 0.0,
                maxStationaryStateIterations_, ecType);   // PC this is probably not meant like this ? Use separate counter ?
                endCriteria.checkMaxIterations(iterationNumber_, ecType);
                x_ = vertices_[iLowest];
                Real low = values_[iLowest];
                P.setFunctionValue(low);
                P.setCurrentValue(x_);
                return ecType;
            }
            // If end criteria is not met, continue
            Real factor = -1.0;
            Real vTry = extrapolate(P, iHighest, factor);
            if ((vTry <= values_[iLowest]) && (factor == -1.0)) {
                factor = 2.0;
                extrapolate(P, iHighest, factor);
            } else if (std::fabs(factor) > QL_EPSILON) {
                if (vTry >= values_[iNextHighest]) {
                    Real vSave = values_[iHighest];
                    factor = 0.5;
                    vTry = extrapolate(P, iHighest, factor);
                    if (vTry >= vSave && std::fabs(factor) > QL_EPSILON) {
                        for (Size i=0; i<=n; i++) {
                            if (i!=iLowest) {
                                #if defined(QL_ARRAY_EXPRESSIONS)
                                vertices_[i] =
                                    0.5*(vertices_[i] + vertices_[iLowest]);
                                #else
                                vertices_[i] += vertices_[iLowest];
                                vertices_[i] *= 0.5;
                                #endif
                                values_[i] = P.value(vertices_[i]);
                            }
                        }
                    }
                }
            }
            // If can't extrapolate given the constraints, exit
            if (std::fabs(factor) <= QL_EPSILON) {
                x_ = vertices_[iLowest];
                Real low = values_[iLowest];
                P.setFunctionValue(low);
                P.setCurrentValue(x_);
                return EndCriteria::StationaryFunctionValue;
            }
        } while (end == false);
        QL_FAIL("optimization failed: unexpected behaviour");
    }
コード例 #20
0
ファイル: fiddle.c プロジェクト: timburrow/ovj3
/*************************************

   fiddle()

**************************************/
int fiddle(int argc, char *argv[], int retc, char *retv[])
{
	int    pwr,cblock,res,dc_correct=TRUE;
	register int i,ntval;
	dpointers  inblock;
	float   a,b,c,d,denom;
	int    ocount;

	/* initialization bits */
	if (i_fiddle(argc,argv))
		ABORT;

	dc_correct=dccorr;
	pwr = fnpower(fn0);
	max=0.0;
	cfcount=0;
	count=0;
	firstrefint=0.0;
	phasetweek=0.0;
	degtorad=3.141592654/180.0;
	ocount=0;
	ntval = 1;
	if (!P_getreal(PROCESSED, "nt", &tmp, 1))
	{
		ntval = (int) (tmp + 0.5);
		if (ntval < 1)
			ntval = 1;
	}
	disp_status("IN3 ");

	/* check range of transforms */
	if (startno>=fidhead.nblocks) startno=fidhead.nblocks-1;
	if (startno<0) {
		startno=0; 
		finishno=fidhead.nblocks; 
		stepno=1;
	}
	if (finishno>fidhead.nblocks) finishno=fidhead.nblocks;
	if (stepno==0) stepno=1;

	/* setup destination fidfile and/or correction function file if requested 
*/
	if (writefg) setupwritefile();
	if (writecfflg) setupwritecf();

	/* start of main loop */
	incno=0;
	t1=0;
	rp0=rp;
	for (cblock = startno; cblock < finishno; cblock+=stepno)
	{
		if ( (res = D_getbuf(D_DATAFILE, fidhead.nblocks, cblock, &inblock)) )
		{
			D_error(res);
			freall(TRUE);
		}
		if ( (inblock.head->status & (S_DATA|S_SPEC|S_FLOAT|S_COMPLEX)) ==
		    (S_DATA|S_SPEC|S_FLOAT|S_COMPLEX) )
		{
			disp_index(cblock+1);
			incno+=1;
			if (verbose) Wscrprintf("Increment no. %d \n",incno);

			if (!aphflg) incrementrp();

			inp = (float *)inblock.data;
			/* DEBUGGING ONLY
			  if (verbose) Wscrprintf("Real part of 1st point of original fid 
%f \n",
			      inp[0]);
			  if (verbose) Wscrprintf("Imag part of 1st point of original fid 
%f \n",
			      inp[1]);
			*/
			/* dc (not normally used!) 
			if (dc_correct)
			  {
			  disp_status("DC ");
			  cmplx_dc(inp, &lvl_re, &lvl_im, &tlt_re, &tlt_im, np0/2, 
CMPLX_DC);
			  vvrramp(inp, 2, inp, 2, lvl_re, tlt_re, np0/2);
			  vvrramp(inp+1, 2, inp+1, 2, lvl_im, tlt_im, np0/2);
			  } */

			/* phase correct spectrum */
			finalph=0.0;
			rotate2(inp,np0/2,lp,rp);
			if (aphflg)
			{
				faph(inp,leftpos,rightpos,&finalph);
				rotate2(inp,np0/2,0.0,finalph);
			}

			/* if baseline then zero imag. */
			if (baseline||hilbert) fiddle_zeroimag();

			/* move first to data1, ready for ift, n.b. fn0==np0 */
			transpmove(inp,data1);

			/* do zeroing for reference region */
			if (solvent) solventextract();
			else
			{
				for (i=0;i<leftpos;i++)
				{
					inp[i]=0.0;
				}
				for (i=rightpos+2;i<np0;i++)
				{
					inp[i]=0.0;
				}

				if (ldcflag) baseline_correct(inp,leftpos,rightpos);
				if (extrap) extrapolate();
			} /* !solvent */
			transpmove(inp,data2);

			/* now do the ift's */
			if (!noift)
			{
				disp_status("IFT1 ");
			
	fft(data1,fn0/2,pwr,0,COMPLEX,COMPLEX,1.0,FTNORM/ntval,np0/2);
				disp_status("IFT2 ");
			
	fft(data2,fn0/2,pwr,0,COMPLEX,COMPLEX,1.0,FTNORM/ntval,np0/2);
			}

			if (makereffg) makeideal();

			/* need to weight data3 to create ideal fid */
			if (makereffg&&!noift)
			{
				disp_status("WT ");
				weightfid(wtfunc,data3,np0w/2,FALSE,COMPLEX);
			}

			if (stopflag<1||stopflag>3)
			{
				/* DEBUGGING ONLY
				  if (verbose) Wscrprintf("Real part of 1st point of 
original fid %f \n",
				      data1[0]);
				  if (verbose) Wscrprintf("Imag part of 1st point of 
original fid %f \n",
				      data1[1]);
				*/
				/* divide (3) by (2) */
				disp_status("DIV ");
				for (i=0;i<npi;i+=2)
				{
					a=data3[i];
					b=data3[i+1];
					c=data2[i];
					d=data2[i+1];
					denom=c*c+d*d;
					data2[i]=(a*c+b*d)/denom;
					data2[i+1]=(b*c-a*d)/denom;
				}

				if (writecfflg) writeoutcf();
				if (readcfflg) readincf();

				/* and multiply by (1) */

				/* DEBUGGING ONLY	
				  if (verbose) Wscrprintf("Real part of 1st point of 
correction function %f \n",
				      data2[0]);
				  if (verbose) Wscrprintf("Imag part of 1st point of 
correction function %f \n",
				      data2[1]);
				*/
				disp_status("MUL ");
				if (!corfunc)
				{
					for (i=0;i<npi;i+=2)
					{
						a=data2[i];
						b=data2[i+1];
						c=data1[i];
						d=data1[i+1];
						inp[i]=(a*c-b*d);
						inp[i+1]=(b*c+a*d);
					}
				}
				/* DEBUGGING ONLY
				  if (verbose) Wscrprintf("Real part of 1st point of 
corrected fid %f \n",
				      inp[0]);
				  if (verbose) Wscrprintf("Imag part of 1st point of 
corrected fid %f \n",
				      inp[1]);
				*/
				/* Halve first point of corrected fid */
				/* hang about, does this do anything??? */
				if (halffg) /* default true */
				{
					data1[0]=0.5*(data1[0]);
					data1[1]=0.5*(data1[1]);
				}

				if (npi<np0)
					for (i=npi;i<np0;i++)
						inp[i]=0.0;
			} /* stopflag not 1 - 3 */

			if (firstfg&&!nosub)
				movmem((char *)inp,(char *)data4,sizeof(float)*np0,1,4);
			if (secondfg&&!nosub)
			{
				disp_status("SUB ");
				submem(inp,data4,np0);
				if (invert) invertmem(inp,np0);
			}

			/* inp contains result fid - write out and/or FT! */
			if (writefg&&!firstfg) writeoutresult();
			if (!noftflag)
			{
				disp_status("FT ");
				fft(inp,fn0/2,pwr,0,COMPLEX,COMPLEX,-1.0,FTNORM/ct,np0/2);
			}

			/* move intermediate result for display if requested */
			if (stopflag||corfunc)
			{
				disp_status("MOVE ");
				switch (stopflag)
				{
				case 1: 
					p=data1; 
					break;
				case 2: 
					p=data2; 
					break;
				case 4: 
					p=data4; 
					break;
				default:
					p=data3; 
					break;
				}
				if (corfunc) p=data2;
				if (difffg&&(stopflag<4))
				{
					if (firstfg) movmem((char *)p,(char
					*)data4,sizeof(float)*np0,1,4);
					if (!firstfg)
					{
						submem(p,data4,np0);
						if (invert) invertmem(p,np0);
					}
				}
				if (noift)
					transpmove(p,inp);
					else
					movmem((char *)p,(char *)inp,sizeof(float)*np0,1,4);
			}

			/* re-phase back to rp,lp */
			disp_status("PHASE ");
			if (!(writefg&&!firstfg)) /* if not both writing and subsequent 
fid */
			{
				rotate2(inp,np0/2,-lp,-rp);
			}
			else rotate2(inp,np0/2,-lp,0.0);

			if (difffg)
			{
				secondfg=!secondfg;
				firstfg=!firstfg;
			}
			if (udifffg)
			{
				secondfg=TRUE;
				firstfg=FALSE;
			}
			if (secondfg||oflag)
				makereffg=FALSE;
			else makereffg=TRUE;

			/* oflag increment */
			if (oflag)
			{
				rp+=odat[ocount];
				ocount++;
				if (ocount>3) ocount=0;
			}
			/* release result */
			if ( (res=D_markupdated(D_DATAFILE,cblock)) )
			{
				D_error(res);
				disp_status("  ");
				freall(TRUE);
			}
			if ( (res = D_release(D_DATAFILE, cblock)) )
			{
				D_error(res);
				disp_status("  ");
				freall(TRUE);
			}
			if (interuption) /* ? not fully working ? */
			{
				Werrprintf("Fiddle processing halted");
				freall(TRUE);
				ABORT;
			}

			if (flag2d)
			{
				if (altfg)
				{
					if ((incno % 2)==0) t1=t1+1/sw1;
				}
				else
				{
					t1=t1+1/sw1;
				}
			}
		}  /* end of if ( (inblock.head->status &c at start of main loop */
	}	/* end of main loop */
	start_from_ft=TRUE;
	releasevarlist();
	appendvarlist("cr");
	Wsetgraphicsdisplay("ds");
	/* free memory */
	freall(FALSE);

	disp_status("  ");
	disp_index(0);
	RETURN;
}
コード例 #21
0
ファイル: Extrapolation.hpp プロジェクト: danx0r/sirikata
 ExtrapolatorBase<Value, TimeType>& updateValue(const TimeType&t, const Value&l) {
     mValuePast=TemporalValueType(t,extrapolate(t));
     mValuePresent.updateValue(t,l);
     return *this;
 }
コード例 #22
0
ファイル: Extrapolation.hpp プロジェクト: danx0r/sirikata
 virtual bool needsUpdate(const TimeType&now,const Value&actualValue) const{
     const UpdatePredicate* mNeedsUpdate=this;
     return (*mNeedsUpdate)(actualValue, extrapolate(now));
 }