Beispiel #1
0
//initialize the U(1) state
void u1two::create_ad()
{
  pars->desc = "U(1)2";

  double **m = createdouble( N );
  double *v = new double[ N ];
  
  double ***adxn = new (double(**[2]));
  adxn[0] = createdouble( N );
  adxn[1] = createdouble( N );

  for(int n=0; n<NS; n++)
  {
    copy_m(m, pars->t[n], N);
    eigvects(m, v, N);
    cout << "v[" << n << "]: ";
    for(int i=0; i<N; i++) cout << v[i] << "; ";
    cout << "\n";

    //take the lowest N2 eigenvectors
    int i;
    for(i=0; i<N2; i++)
      for(int j=0; j<N; j++) adxn[n][j][i] = m[i][j]; //note that the eigenvalue index is the last index in adx!

    if(i<N) {
      //cout << "abs diff " << abs(v[i]-v[i-1]) << "\n";
      if( abs(v[i]-v[i-1]) < 1e-8 )
        cout << "WARN: degenerate state\n";
      cout << "Fermi energy is " << v[i-1] << ", " << v[i] << " at position " << i-1 << "\n"; 
    }
  }
  
  for(int j=0; j<N*N; j++) adx[j] = 0.;
  
  for(int i=0; i<N; i++) //mutliply the two matrices to get adx
    for(int j=0; j<N; j++)
      for(int n=0; n<N2; n++)
        adx[i*N+j] += adxn[0][i][n]*adxn[1][j][n];

  destroy(m, N);
  delete[] v;
  destroy(adxn[0], N);
  destroy(adxn[1], N);
  delete[] adxn;

  normalize( 4. );
}
Beispiel #2
0
/* A merge routine. Merges the sub-arrays A [p..q] and A [q + 1..r].
 * Uses two arrays 'left' and 'right' in the merge operation.
 */
static inline void merge_m(data_t *A, int p, int q, int r) 
{ 
	assert(A) ;
	assert(p <= q) ;
	assert((q + 1) <= r) ;
	int n1 = q - p + 1;
	int n2 = r - q;

	data_t * left = 0; 
     	mem_alloc(&left, n1 + 1) ;
        if (left == NULL)
        {
                mem_free (&left) ;
                return ;
        }
	
	copy_m (&(A [p]), left, n1) ;
	left [n1] = UINT_MAX ;

	unsigned int * __restrict Aptr = &(A[p]);
	unsigned int * __restrict leftptr = left;
	unsigned int * __restrict rightptr = &(A[q+1]);

	while (n1 > 0 && n2 > 0) {

	  long cmp = (*leftptr <= *rightptr);
	  long min = *rightptr ^ ((*leftptr ^ *rightptr) & -(cmp));

	  *Aptr++ = min;
	  leftptr += cmp; n1 -= cmp;
	  rightptr += !cmp; n2 -= !cmp;
	}

	while (n1 > 0) {
	  *Aptr++ = *leftptr++;
	  n1--;
	}

	mem_free(&left) ;
}