Ejemplo n.º 1
0
int main ()
{
	CPose3DQuat cpose;
	TPoint3D point;
	kftype out_jacob_dryp_dpoint[3][3];
	kftype out_jacob_dryp_dpose[3][7];
	unsigned int i,j;

	cpose = (CPose3DQuat) {random_number_gen(), random_number_gen(),
		random_number_gen(), random_number_gen(),
		random_number_gen(), random_number_gen(),
		random_number_gen()};

	point = (TPoint3D) {
		random_number_gen(), 
		random_number_gen(),
		random_number_gen()
	};

	for (i=0; i<3; i++)
		for (j=0; j<3; j++)
			out_jacob_dryp_dpoint[i][j] = random_number_gen();

	for (i=0; i<3; i++)
		for (j=0; j<7; j++)
			out_jacob_dryp_dpose[i][j] = random_number_gen();

	sphericalCoordinates(cpose,point,
		out_jacob_dryp_dpoint,
		out_jacob_dryp_dpose
	);

	printf ("SLAM Sperical Coords ACC Done. \n");
	return 0;
}
Ejemplo n.º 2
0
Archivo: type1.c Proyecto: chrr/libECP
doubleArray
calcChi(Type1 *t1, double *U_L, ECP *U,
	double *rAC, const double dAC, double *rBC, const double dBC, 
	const int la, const int shella, const int offseta, const int shifta, doubleArray uspA,  
	const int lb, const int shellb, const int offsetb, const int shiftb, doubleArray uspB) {
  const int N_a = t1->contraction[shella];
  const double *zs_a = t1->a + offseta;
  const double *cs_a = t1->d + offseta;
  const int N_b = t1->contraction[shellb];
  const double *zs_b = t1->a + offsetb;
  const double *cs_b = t1->d + offsetb;
  int pa, pb;
  double ca, za, cb, zb, factor;
  double P[3], S[3];
  const int lab = la+lb;
  int ax, ay, az, bx, by, bz;
  int i, j, p, l, m, lmax, lx, ly, lz;
  double *rsph, *PM = t1->poly2sph;
  int *ijkIndex = t1->ijkIndex;
  const int ijkDim = t1->ijkDim;
  const int tmDim = L_DIM(t1->tmDim);
  doubleArray Q, chi = doubleArray_new(2, C_DIM(la), C_DIM(lb));
  int incQ, inc = chi.dim[2];
  
  for(pa=0; pa<N_a; pa++) {
    za = zs_a[pa];
    ca = cs_a[pa]; 
    /* nth derivative: extra factor of zeta^n */
    for(p=0; p<shifta; p++)
      ca *= za;
    
    for(pb=0; pb<N_b; pb++) {
      zb = zs_b[pb];
      cb = cs_b[pb];
      for(p=0; p<shiftb; p++)
	cb *= zb;

      /* note: use of rAC,rBC introduces change in sign */
      for (p=0; p<3; p++) 
	P[p] = 2.0*(za*rAC[p] + zb*rBC[p]);
      sphericalCoordinates(P, S);
      rsph = realSphericalHarmonics(lab, S[1], S[2], t1->fac, t1->dfac);
            
      /* bessel weight 's' corresponds to S[0] */
      Q = calcQ(t1, U_L, U, S[0], lab, dAC, ca, za, shifta, dBC, cb, zb, shiftb);
      if (NULL==Q.array) {
	doubleArray_free(chi);
	free(rsph);
	return chi;
      }
      incQ = Q.dim[2];

      /* construct cartesian components */
      // FIXME - ??? for(alpha=0; alpha<=la; alpha++) {
      //               for(c1=0; c1<IJK_DIM(alpha); c1++) { ...
      for(ax=0; ax<=la; ax++) {
	for(ay=0; ay<=la-ax; ay++) {
	  for(az=0; az<=la-ax-ay; az++) {
	    i = ijkIndex[ax*ijkDim*ijkDim + ay*ijkDim + az];
	    for(bx=0; bx<=lb; bx++) {
	      lx = ax + bx;
	      for(by=0; by<=lb-bx; by++) {
		ly = ay + by;
		for(bz=0; bz<=lb-bx-by; bz++) {
		  j = ijkIndex[bx*ijkDim*ijkDim + by*ijkDim + bz];
		  lz = az + bz;
		  lmax = lx + ly + lz;

 		  /* final index for P matrix */
		  p = ijkIndex[lx*ijkDim*ijkDim + ly*ijkDim + lz];

		  for(l=lmax; l>=0; l-=2) {
		    factor = 0.0;
		    for(m=0; m<2*l+1; m++) {
		      factor += rsph[LM_INDEX(l,m)] * PM[p*tmDim+LM_INDEX(l,m)];
		    }
		    chi.array[i*inc+j] += factor * Q.array[lmax*incQ+l];
		  }
		  //printf(" libecp type1:  %d,%d  %d,%d  chi[%d,%d,%d][%d,%d,%d] = %.12f\n", la, lb, pa, pb, ax, ay, az, bx, by, bz, chi.array[i*inc+j]);
		}
	      }
	    }
	  }
	}
      }
      doubleArray_free(Q);
      free(rsph);
    }
  }

  return chi;
}