Beispiel #1
0
 Lattice Hx () {
   Lattice H(2,cpx(.5,sqrt(3)/2));
   H.bond(0,1).bond(0,1,coo(-1,0)).bond(0,1,coo(0,-1));
   H.z[0]=0;
   H.z[1]=cpx(1,1)/cpx(3);
   return H;
 }
Beispiel #2
0
 Lattice T2 () {
   Lattice T2(2,cpx(0,sqrt(3.0)));
   T2.bond(0,1).bond(0,0,coo(1,0)).bond(1,0,coo(1,0)).bond(1,0,coo(0,1)).bond(1,0,coo(1,1)).bond(1,1,coo(1,0));
   T2.z[0]=0;
   T2.z[1]=cpx(.5,.5);
   return T2;
 }
Beispiel #3
0
 Lattice K () {
   Lattice K(3,cpx(.5,sqrt(3)/2));
   K.bond(0,1).bond(0,2).bond(1,2).bond(1,0,coo(1,0)).bond(2,0,coo(0,1)).bond(1,2,coo(1,-1));
   K.z[0]=0;
   K.z[1]=.5;
   K.z[2]=cpx(0,.5);
   return K;
 }
Beispiel #4
0
 Lattice H2 () {
   Lattice H2(4,cpx(0,sqrt(3.0)));
   H2.bond(0,1).bond(1,2).bond(2,3).bond(3,0,coo(0,1)).bond(2,1,coo(1,0)).bond(3,0,coo(1,1));
   H2.z[0]=0;
   H2.z[1]=cpx(0,1.0/3);
   H2.z[2]=cpx(.5,.5);
   H2.z[3]=cpx(.5,5.0/6);
   return H2;
 }
Beispiel #5
0
 Lattice SO () {
   Lattice SO(4);
   SO.bond(0,1).bond(1,2).bond(2,3).bond(3,0).bond(2,0,coo(0,1)).bond(1,3,coo(1,0));
   SO.z[0]=cpx(.5,.25);
   SO.z[1]=cpx(.75,.5);
   SO.z[2]=cpx(.5,.75);
   SO.z[3]=cpx(.25,.5);
   return SO;
 }
Beispiel #6
0
 Lattice G67 () {
   Lattice G67(3, cpx(0,sqrt(6.0/7)));
   G67.bond(0,1).bond(0,2).bond(1,2).bond(0,0,coo(1,0)).bond(0,0,coo(0,1)).bond(0,1,coo(-1,0))
     .bond(0,1,coo(0,-1)).bond(0,1,coo(-1,-1)).bond(2,0,coo(0,1));
   G67.z[0]=0;
   G67.z[1]=cpx(.5,.5);
   G67.z[2]=cpx(1.0/6,.5);
   return G67;
 }
Beispiel #7
0
 Lattice SV () {
   Lattice SV(4);
   SV.bond(0,1).bond(1,2).bond(2,3).bond(3,0).bond(1,3).bond(1,0,coo(1,0)).bond(2,3,coo(1,0))
     .bond(1,3,coo(1,0)).bond(0,3,coo(0,-1)).bond(1,2,coo(0,-1)).bond(2,0,coo(1,1)).bond(3,1,coo(0,1));
   SV.z[0]=0;
   SV.z[1]=.5;
   SV.z[2]=cpx(.5,.5);
   SV.z[3]=cpx(0,.5);
   return SV;
 }
Beispiel #8
0
void cp_and_padding(Image<cpx> &ori, Image<T> &img){
    for(int i = 0; i < ori.rows; ++i){
        for(int j = 0; j < ori.cols; ++j){
            if(i < img.rows and j < img.cols)
                ori(i,j) = cpx(img(i,j),0);
            else
                ori(i,j) = cpx(0,0);
        }
    }
}
Beispiel #9
0
 Lattice C5 () {
   Lattice C5(5);
   C5.bond(1,0).bond(1,4).bond(0,2).bond(0,3).bond(0,4).bond(2,3).bond(3,4).bond(2,1,coo(1,0)).bond(2,4,coo(1,0))
     .bond(3,4,coo(1,0)).bond(3,1,coo(1,1)).bond(3,0,coo(1,1)).bond(3,2,coo(0,1)).bond(3,0,coo(0,1)).bond(4,0,coo(0,1));
   C5.z[0]=.25;
   C5.z[1]=cpx(0,.125);
   C5.z[2]=cpx(.75,.25);
   C5.z[3]=cpx(.75,.75);
   C5.z[4]=cpx(.25,.5);
   return C5;
 }
Beispiel #10
0
 Lattice K2 () {
   Lattice K2(6,cpx(0,sqrt(3)));
   K2.bond(0,1).bond(0,2).bond(1,2).bond(2,3).bond(2,4).bond(3,4).bond(4,5)
     .bond(1,0,coo(1,0)).bond(4,3,coo(1,0)).bond(5,3,coo(1,0)).bond(5,1,coo(0,1)).bond(5,0,coo(1,1));
   K2.z[0]=0;
   K2.z[1]=.5;
   K2.z[2]=cpx(.25,.25);
   K2.z[3]=cpx(0,.5);
   K2.z[4]=cpx(.5,.5);
   K2.z[5]=cpx(.75,.75);
   return K2;
 }
Beispiel #11
0
int main(void)
{
  printf("If rows come in identical pairs, then everything works.\n");
  
  cpx a[8] = {0, 1, cpx(1,3), cpx(0,5), 1, 0, 2, 0};
  cpx b[8] = {1, cpx(0,-2), cpx(0,1), 3, -1, -3, 1, -2};
  cpx A[8];
  cpx B[8];
  FFT(a, A, 1, 8, 1);
  FFT(b, B, 1, 8, 1);
  
  for(int i = 0 ; i < 8 ; i++)
  {
    printf("%7.2lf%7.2lf", A[i].a, A[i].b);
  }
  printf("\n");
  for(int i = 0 ; i < 8 ; i++)
  {
    cpx Ai(0,0);
    for(int j = 0 ; j < 8 ; j++)
    {
      Ai = Ai + a[j] * EXP(j * i * two_pi / 8);
    }
    printf("%7.2lf%7.2lf", Ai.a, Ai.b);
  }
  printf("\n");
  
  cpx AB[8];
  for(int i = 0 ; i < 8 ; i++)
    AB[i] = A[i] * B[i];
  cpx aconvb[8];
  FFT(AB, aconvb, 1, 8, -1);
  for(int i = 0 ; i < 8 ; i++)
    aconvb[i] = aconvb[i] / 8;
  for(int i = 0 ; i < 8 ; i++)
  {
    printf("%7.2lf%7.2lf", aconvb[i].a, aconvb[i].b);
  }
  printf("\n");
  for(int i = 0 ; i < 8 ; i++)
  {
    cpx aconvbi(0,0);
    for(int j = 0 ; j < 8 ; j++)
    {
      aconvbi = aconvbi + a[j] * b[(8 + i - j) % 8];
    }
    printf("%7.2lf%7.2lf", aconvbi.a, aconvbi.b);
  }
  printf("\n");
  
  return 0;
}
Beispiel #12
0
 Lattice Z2C () {
   Lattice Z2C(2);
   Z2C.bond(0,0,coo(1,0)).bond(0,0,coo(0,1)).bond(0,1).bond(0,1,coo(-1,0)).bond(0,1,coo(0,-1)).bond(0,1,coo(-1,-1));
   Z2C.z[0]=0;
   Z2C.z[1]=cpx(.5,.5);
   return Z2C;
 }
Beispiel #13
0
vector<cpx> cl_fft<cpx>::run(const vector<cpx> &input)
{
	cl_event upload_unmap_evt, start_evt, download_map_evt, *kernel_evts = new cl_event[launches.size()];
	cl_int err;

	// Upload
	cl_float2 *input_buffer = (cl_float2*)clEnqueueMapBuffer(command_queue,
		v_samples,
		CL_TRUE,
		CL_MAP_WRITE,
		0,
		samplesMemSize,
		0,
		NULL,
		NULL,
		&err);
	CL_CHECK_ERR("clEnqueueMapBuffer", err);

	for (int i = 0; i < samplesPerRun; i++)
	{
		input_buffer[i].x = real(input[i]);
		input_buffer[i].y = imag(input[i]);
	}

	CL_CHECK_ERR("clEnqueueUnmapMemObject", clEnqueueUnmapMemObject(command_queue, v_samples, input_buffer, 0, NULL, &upload_unmap_evt));

	// Calcola la FFT
	cl_mem v_out = runInternal(v_samples, &start_evt, kernel_evts);

	// Download
	vector<cpx> result(samplesPerRun);
	cl_float2 *output_buffer = (cl_float2*)clEnqueueMapBuffer(command_queue,
		v_out,
		CL_TRUE,
		CL_MAP_READ,
		0,
		tmpMemSize,
		1,
		&kernel_evts[launches.size() - 1],
		&download_map_evt,
		&err);
	CL_CHECK_ERR("clEnqueueMapBuffer", err);

	for (int i = 0; i < samplesPerRun; i++)
		result[i] = cpx(output_buffer[i].x, output_buffer[i].y);

	CL_CHECK_ERR("clEnqueueUnmapMemObject", clEnqueueUnmapMemObject(command_queue, v_out, output_buffer, 0, NULL, NULL));

	printStatsAndReleaseEvents(upload_unmap_evt, start_evt, kernel_evts, download_map_evt);

	delete[] kernel_evts;

	return result;
}
Beispiel #14
0
static char * CPX2() {
    CPU *c = getCPU();
    int8_t operand = 75;
    OP_CODE_INFO *o = getOP_CODE_INFO(operand,0,modeImmediate);
    setRegByte(c,IND_X,59);
    cpx(c,o);
    mu_run_test_with_args(testRegStatus,c,"10100000",
            "          NVUBDIZC    NVUBDIZC\nCPX2 err, %s != %s");
    freeOP_CODE_INFO(o);
    free(c);
    return 0;
}
intx fastmul(const intx &an, const intx &bn) {
    string as = an.to_string(), bs = bn.to_string();
    int n = size(as), m = size(bs), l = 1,
        len = 5, radix = 100000,
        *a = new int[n], alen = 0,
        *b = new int[m], blen = 0;
    memset(a, 0, n << 2);
    memset(b, 0, m << 2);
    for (int i = n - 1; i >= 0; i -= len, alen++)
        for (int j = min(len - 1, i); j >= 0; j--)
            a[alen] = a[alen] * 10 + as[i - j] - '0';
    for (int i = m - 1; i >= 0; i -= len, blen++)
        for (int j = min(len - 1, i); j >= 0; j--)
            b[blen] = b[blen] * 10 + bs[i - j] - '0';
    while (l < 2*max(alen,blen)) l <<= 1;
    cpx *A = new cpx[l], *B = new cpx[l];
    rep(i,0,l) A[i] = cpx(i < alen ? a[i] : 0, 0);
    rep(i,0,l) B[i] = cpx(i < blen ? b[i] : 0, 0);
    fft(A, l); fft(B, l);
    rep(i,0,l) A[i] *= B[i];
    fft(A, l, true);
    ull *data = new ull[l];
    rep(i,0,l) data[i] = (ull)(round(real(A[i])));
    rep(i,0,l-1)
        if (data[i] >= (unsigned int)(radix)) {
            data[i+1] += data[i] / radix;
            data[i] %= radix;
        }
    int stop = l-1;
    while (stop > 0 && data[stop] == 0) stop--;
    stringstream ss;
    ss << data[stop];
    for (int i = stop - 1; i >= 0; i--)
        ss << setfill('0') << setw(len) << data[i];
    delete[] A; delete[] B;
    delete[] a; delete[] b;
    delete[] data;
    return intx(ss.str());
}
Beispiel #16
0
 cpx Lattice::tau_rw () const {
   double a=0, b=0, c=0;
   for (unsigned k=0; k<n; ++k)
     for (unsigned l=0; l<adj[k].size(); ++l) {
       const Lattice_place &m = adj[k][l];
       cpx u = cpx(m.z.x,m.z.y) + z[m.k] - z[k];
       a += u.imag()*u.imag();
       b += 2*u.real()*u.imag();
       c += u.real()*u.real();
     }
   cpx delta = b*b - 4*a*c;
   cpx t = (-b + sqrt(delta))/(2*a);
   return (t.imag()>0 ? t : conj(t));
 }
static int runTest(cl_context context, cl_command_queue command_queue, I *cl_algorithm_instance, int N, bool print, bool check)
{
	vector<T> input = generateTestData<T>(N);
	vector<cpx> output(N);
	cl_int err;

	const size_t samplesMemSize = cl_deviceDataSize<T>(N);
	cl_mem v_output, v_input = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, samplesMemSize, &input[0], &err);
	CL_CHECK_ERR("clCreateBuffer", err);

	cl_event kernel_evt;
	v_output = cl_algorithm_instance->run(v_input, &kernel_evt);

	CL_CHECK_ERR("clReleaseMemObject", clReleaseMemObject(v_input));

	cl_float2 *output_buffer = (cl_float2*)clEnqueueMapBuffer(command_queue,
		v_output,
		CL_TRUE,
		CL_MAP_READ,
		0,
		N * sizeof(cl_float2),
		1,
		&kernel_evt,
		NULL,
		&err);
	CL_CHECK_ERR("clEnqueueMapBuffer", err);

	for (int i = 0; i < N; i++)
		output[i] = cpx(output_buffer[i].x, output_buffer[i].y);

	CL_CHECK_ERR("clEnqueueUnmapMemObject", clEnqueueUnmapMemObject(command_queue, v_output, output_buffer, 0, NULL, NULL));

	if (print)
		cerr << output << endl;

	if (check)
	{
#ifdef ALLOW_NPOT
		fprintf(stderr, "Calcolo serial naive DFT per riferimento...\n");
		const vector<cpx> ref = serial_naive_dft(input);
#else
		fprintf(stderr, "Calcolo serial non-recursive FFT per riferimento...\n");
		const vector<cpx> ref = serial_nonrecursive_fft(input);
#endif
		fprintf(stderr, "Distanza massima: %g\n", maxAbsDistance(output, ref));

	}

	return EXIT_SUCCESS;
}
Beispiel #18
0
QVector<float> SpectrumAnalyzerRangeData::runFFT(cl_mem samplesHistory, cl_int historyOffset, cl_int historyLength)
{
	cl_event presum_evt, algo_evt;

	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 0, sizeof(cl_mem), &samples));
	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 1, sizeof(cl_mem), &samplesHistory));
	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 2, sizeof(cl_int), &historyOffset));
	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 3, sizeof(cl_int), &historyLength));
	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 4, sizeof(cl_int), &presumWindows));
	CL_CHECK_ERR("clEnqueueNDRangeKernel", clEnqueueNDRangeKernel(command_queue,
		circsum,
		1,
		NULL,
		&windowSize,
		&presumGroupSize,
		0,
		NULL,
		&presum_evt
	));

	clEnqueueWaitForEvents(command_queue, 1, &presum_evt);

	cl_mem output = algorithm.run(samples, &algo_evt);

	QVector<float> risultato(windowSize);

	cl_int err;
	cl_float2 *output_buffer = (cl_float2*)clEnqueueMapBuffer(command_queue,
		output,
		CL_TRUE,
		CL_MAP_READ,
		0,
		windowSize * sizeof(cl_float2),
		1,
		&algo_evt,
		NULL,
		&err);
	CL_CHECK_ERR("clEnqueueMapBuffer", err);

	for (int i = 0; i < windowSize; i++)
		risultato[i] = abs(cpx(output_buffer[i].x, output_buffer[i].y));

	CL_CHECK_ERR("clEnqueueUnmapMemObject", clEnqueueUnmapMemObject(command_queue, output, output_buffer, 0, NULL, NULL));

	CL_CHECK_ERR("clReleaseEvent", clReleaseEvent(presum_evt));
	CL_CHECK_ERR("clReleaseEvent", clReleaseEvent(algo_evt));

	return risultato;
}
Beispiel #19
0
void FFT::rv (
   double *real ,  // In: 0,2,4,... Out:Real parts
   double *imag    // In: 1,3,5,... Out: Imaginary parts
   )
{
   int i, j, lim ;
   double theta, wr, wi, wkr, wki, t, h1r, h1i, h2r, h2i ;

   cpx ( real , imag , 1 ) ;

/*
   Use the guaranteed zero imag[0] to actually return real[n]
*/

   t = real[0] ;
   real[0] = t + imag[0] ;
   imag[0] = t - imag[0] ;

/*
   Now do the remainder through n-1
*/

   theta = PI / (double) npts ;
   t = sin ( 0.5 * theta ) ;
   wr = 1.0 + (wkr = -2.0 * t * t) ;
   wi = wki = sin ( theta ) ;

   lim = (npts % 2)  ?  npts/2+1 : npts/2 ;
   for (i=1 ; i<lim ; i++) {
      j = npts - i ;
      h1r =  0.5 * (real[i] + real[j]) ;
      h1i =  0.5 * (imag[i] - imag[j]) ;
      h2r =  0.5 * (imag[i] + imag[j]) ;
      h2i = -0.5 * (real[i] - real[j]) ;
      real[i] =  wr * h2r  -  wi * h2i  +  h1r ;
      imag[i] =  wr * h2i  +  wi * h2r  +  h1i ;
      real[j] = -wr * h2r  +  wi * h2i  +  h1r ;
      imag[j] =  wr * h2i  +  wi * h2r  -  h1i ;
      t = wr ;
      wr += t * wkr  -  wi * wki ;
      wi += t * wki  +  wi * wkr ;
      }
}
Beispiel #20
0
void FFT::irv (
   double *real ,  // In: Real parts         Out: 0,2,4,...
   double *imag    // In: Imaginary parts    Out: 1,3,5,...
   )
{
   int i, j, lim ;
   double theta, wr, wi, wkr, wki, t, h1r, h1i, h2r, h2i ;

   theta = -PI / (double) npts ;
   t = sin ( 0.5 * theta ) ;
   wr = 1.0 + (wkr = -2.0 * t * t) ;
   wi = wki = sin ( theta ) ;

   lim = (npts % 2)  ?  npts/2+1 : npts/2 ;
   for (i=1 ; i<lim ; i++) {
      j = npts - i ;
      h1r =  0.5 * (real[i] + real[j]) ;
      h1i =  0.5 * (imag[i] - imag[j]) ;
      h2r = -0.5 * (imag[i] + imag[j]) ;
      h2i =  0.5 * (real[i] - real[j]) ;
      real[i] =  wr * h2r  -  wi * h2i  +  h1r ;
      imag[i] =  wr * h2i  +  wi * h2r  +  h1i ;
      real[j] = -wr * h2r  +  wi * h2i  +  h1r ;
      imag[j] =  wr * h2i  +  wi * h2r  -  h1i ;
      t = wr ;
      wr += t * wkr  -  wi * wki ;
      wi += t * wki  +  wi * wkr ;
      }

   t = real[0] ;
   real[0] = 0.5 * (t + imag[0]) ;
   imag[0] = 0.5 * (t - imag[0]) ;

   cpx ( real , imag , -1 ) ;

   t = 1.0 / npts ;
   for (i=0 ; i<npts ; i++) {
      real[i] *= t ;
      imag[i] *= t ;
      }
}
void serial_nonrecursive_fft_step(const vector<T> &vec_in, vector<cpx> &vec_out, int W)
{
	const int N = vec_in.size();
	const int H = N/W;
	int dest_i = 0;

	for (int k = 0; k < H/2; k++)
	{
		const int src_y1 = 2*k;
		const int src_y2 = 2*k+1;
		const cpx twiddle_factor = exp(cpx(0, M_PI_F/H*-2.f*k));

		for (int src_x = 0; src_x < W; src_x++)
		{
			cpx p1 = vec_in[src_y1*W + src_x];
			cpx p2 = vec_in[src_y2*W + src_x] * twiddle_factor;

			vec_out[dest_i] = p1 + p2;
			vec_out[dest_i + N/2] = p1 - p2;
			dest_i++;
		}
	}
}
Beispiel #22
0
Handle(Geom_BSplineCurve) CFunctionToBspline::CFunctionToBsplineImpl::Curve()
{
    bool interpolate = true;
    
    std::vector<ChebSegment> segments = approxSegment(_umin, _umax, 1);
    
    int N = _degree + 1;
    math_Matrix Mt = monimial_to_bezier(N)*cheb_to_monomial(N);
    
    // get estimated error and create bspline segments
    std::vector<Handle(Geom_BSplineCurve)> curves;
    double errTotal = 0.;
    std::vector<ChebSegment>::iterator it = segments.begin();
    for (; it != segments.end(); ++it) {
        // get control points
        ChebSegment& seg = *it;
        
        math_Vector cpx = Mt*seg.cx;
        math_Vector cpy = Mt*seg.cy;
        math_Vector cpz = Mt*seg.cz;
        
        TColgp_Array1OfPnt cp(1,cpx.Length());
        for (int i = 1; i <= cpx.Length(); ++i) {
            gp_Pnt p(cpx(i-1), cpy(i-1), cpz(i-1));
            cp.SetValue(i, p);
        }
        
        if (interpolate) {
            gp_Pnt pstart(_xfunc.value(seg.umin), _yfunc.value(seg.umin), _zfunc.value(seg.umin));
            gp_Pnt pstop (_xfunc.value(seg.umax), _yfunc.value(seg.umax), _zfunc.value(seg.umax));
            cp.SetValue(1, pstart);
            cp.SetValue(cpx.Length(), pstop);
        }
        
        // create knots and multiplicity vector
        TColStd_Array1OfReal knots(1,2);
        knots.SetValue(1, seg.umin);
        knots.SetValue(2, seg.umax);
        TColStd_Array1OfInteger mults(1,2);
        mults.SetValue(1, _degree+1);
        mults.SetValue(2, _degree+1);
        
        Handle(Geom_BSplineCurve) curve = new Geom_BSplineCurve(cp, knots, mults, _degree);
        curves.push_back(curve);
        
        if (seg.error > errTotal) {
            errTotal = seg.error;
        }
    }
    _err = errTotal;
     
    // concatenate c1 the bspline curves
    Handle(Geom_BSplineCurve) result = concatC1(curves);

#ifdef DEBUG
    LOG(INFO) << "Result of BSpline approximation of function:";
    LOG(INFO) << "    approximation error = " << errTotal;
    LOG(INFO) << "    number of control points = " << result->NbPoles();
    LOG(INFO) << "    number of segments = " << curves.size();
#endif
    return result;
}
Beispiel #23
0
void pulsesequence()
{
   char    c1d[MAXSTR];               /* option to record only 1D C13 spectrum */
   int     ncyc;
   double  tau1 = 0.002,         			          /*  t1 delay */
           post_del = 0.0,
           pwClvl = getval("pwClvl"), 	  /* coarse power for C13 pulse */
           pwC = getval("pwC"),     	  /* C13 90 degree pulse length at pwClvl */
	   compC = getval("compC"),
	   compH = getval("compH"),
	   mixpwr = getval("mixpwr"),
	   jCH = getval("jCH"),
	   gt0 = getval("gt0"),  		       
	   gt1 = getval("gt1"),  		       
	   gt2 = getval("gt2"),  		       
	   gzlvl0 = getval("gzlvl0"),
	   gzlvl1 = getval("gzlvl1"),
	   gzlvl2 = getval("gzlvl2"),
	   grec = getval("grec"),
	   phase = getval("phase");

           getstr("c1d",c1d);
	   
           ncyc=1;
           if(jCH > 0.0)
             tau1 = 0.25/jCH;

           dbl(ct, v1);                     /* v1 = 0 */
           mod4(v1,oph);
           hlv(ct,v2);
           add(v2,v1,v2);
           if (phase > 1.5)
             incr(v1);                      /* hypercomplex phase increment */           

           initval(2.0*(double)((int)(d2*getval("sw1")+0.5)%2),v10); 
           add(v1,v10,v1);
           add(oph,v10,oph);
           mod4(v1,v1);  mod4(v2,v2); mod4(oph,oph); 
           assign(zero,v3);

           if(FIRST_FID) 
	   {
	     HHmix = pbox_mix("HHmix", "DIPSI2", mixpwr, pw*compH, tpwr);  
	     if(c1d[A] == 'n')
	     {
	       opx("CHdec"); setwave("WURST2 30k/1.2m"); pbox_par("steps","600"); cpx(pwC*compC, pwClvl);
	       CHdec = getDsh("CHdec");
	     }
	   }
	   ncyc = (int) (at/HHmix.pw) + 1;
	   post_del = ncyc*HHmix.pw - at;
	            
             
/* BEGIN PULSE SEQUENCE */

      status(A);

	zgradpulse(gzlvl0, gt0);
	rgpulse(pw, zero, 0.0, 0.0);  /* destroy H-1 magnetization*/
	zgradpulse(gzlvl0, gt0);
	delay(1.0e-4);
	obspower(tpwr);
	txphase(v1);
        decphase(zero);
        dec2phase(zero);

        presat();
	obspower(tpwr);
        	
	delay(1.0e-5);

      status(B);

        if(c1d[A] == 'y')
	{
   	  rgpulse(pw,v1,0.0,0.0);                 /* 1H pulse excitation */
          delay(d2);
   	  rgpulse(pw,two,0.0,0.0);                 /* 1H pulse excitation */
          assign(oph,v3);
	}
	else
	{
          decunblank(); pbox_decon(&CHdec);

   	  rgpulse(pw,v1,0.0,0.0);                 /* 1H pulse excitation */
   	  txphase(zero);
   	
          delay(d2);

          pbox_decoff(); decblank();  
          decpower(pwClvl); decpwrf(4095.0);
   	  
	  delay(tau1 - POWER_DELAY);
          simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);
          txphase(one); decphase(one); dec2phase(one);
	  delay(tau1);
          simpulse(pw, pwC, one, one, 0.0, 0.0);
          txphase(zero); decphase(zero); dec2phase(zero);
	  delay(tau1);
          simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);
	  delay(tau1);
          simpulse(0.0, pwC, zero, zero, 0.0, 0.0);
        }
	zgradpulse(gzlvl1, gt1);
   	delay(grec);
        simpulse(0.0, pwC, zero, v3, 0.0, rof2);
        
        txphase(v2);
        obsunblank(); pbox_xmtron(&HHmix);  

      status(C);
      
        setactivercvrs("ny");
        startacq(alfa);
        acquire(np,1.0/sw);
        endacq();
        
	delay(post_del);
        pbox_xmtroff(); obsblank();
        zgradpulse(gzlvl2, gt2);
        obspower(tpwr);
   	delay(grec);
   	rgpulse(pw,zero,0.0,rof2);                 /* 1H pulse excitation */
   	        
      status(D);
      
        setactivercvrs("yn");
        startacq(alfa);
        acquire(np,1.0/sw);
        endacq();

}		 
Beispiel #24
0
cpx EXP(double theta) {
    return cpx(cos(theta), sin(theta));
}
Beispiel #25
0
cpx operator/(cpx a, cpx b) {
    cpx r = a * b.bar();
    return cpx(r.a / b.modsq(), r.b / b.modsq());
}
Beispiel #26
0
cpx operator*(cpx a, cpx b) {
    return cpx(a.a * b.a - a.b * b.b, a.a * b.b + a.b * b.a);
}
Beispiel #27
0
cpx operator+(cpx a, cpx b) {
    return cpx(a.a + b.a, a.b + b.b);
}
Beispiel #28
0
 cpx bar(void) const {
     return cpx(a, -b);
 }
Beispiel #29
0
  void Lattice::optimize (double f (Lattice const &), double eps) {
    double cost = f(*this);
    double old_cost = cost + eps + 1;
    double tmp_cost = cost;
    while (old_cost - cost > eps) {
      old_cost = cost;
      double delta = sqrt(cost)/10;

      tau += cpx(delta,0); tmp_cost = f(*this);
      if (tmp_cost < cost) cost = tmp_cost;
      else {
        tau -= cpx(2*delta,0); tmp_cost = f(*this);
        if (tmp_cost < cost) cost = tmp_cost;
        else tau += cpx(delta,0);
      }

      tau += cpx(0,delta); tmp_cost = f(*this);
      if (tmp_cost < cost) cost = tmp_cost;
      else {
        tau -= cpx(0,2*delta); tmp_cost = f(*this);
        if (tmp_cost < cost) cost = tmp_cost;
        else tau += cpx(0,delta);
      }

      for (unsigned i=0; i<n; ++i) {
        if (i>0) {
          z[i] += cpx(delta,0); tmp_cost = f(*this);
          if (tmp_cost < cost) cost = tmp_cost;
          else {
            z[i] -= cpx(2*delta,0); tmp_cost = f(*this);
            if (tmp_cost < cost) cost = tmp_cost;
            else z[i] += cpx(delta,0);
          }

          z[i] += cpx(0,delta); tmp_cost = f(*this);
          if (tmp_cost < cost) cost = tmp_cost;
          else {
            z[i] -= cpx(0,2*delta); tmp_cost = f(*this);
            if (tmp_cost < cost) cost = tmp_cost;
            else z[i] += cpx(0,delta);
          }
        }

        r[i] += delta; tmp_cost = f(*this);
        if (tmp_cost < cost) cost = tmp_cost;
        else {
          r[i] -= 2*delta; tmp_cost = f(*this);
          if (tmp_cost < cost) cost = tmp_cost;
          else r[i] += delta;
        }
      }
    }
  }
Beispiel #30
0
 Lattice T() {
   Lattice T(1,cpx(.5,sqrt(3)/2));
   T.bond(0,0,coo(1,0)).bond(0,0,coo(0,1)).bond(0,0,coo(-1,1));
   T.z[0]=0;
   return T;
 }