double lsfit(ATOM atm1[], ATOM atm2[], ATOM atm3[],int n) { typedef struct { double x; double y; double z; } CORD; int i,j,k; int ict; int ix,iy,iz; int iflag; /* ict: counter for number of iterations. must do at least 3 iterations. ix, iy,iz: pointer used in iterative least squares. may have the value 1,2,3 the value changes on each iteration. */ double tol=0.00001; double sig,gam, sg, bb,cc; CORD *x0; CORD *x1; CORD *xyzfit; double aa[3][3]; double rot[3][3]; double cg0[3]; double cg1[3]; double an; double rms,ssum; x0 = (CORD *) malloc(sizeof(CORD) * (n +10)); if (x0 == NULL) { fprintf(stdout, "memory allocation error for *name in lsfit()\n"); exit(1); } x1 = (CORD *) malloc(sizeof(CORD) * (n +10)); if (x1 == NULL) { fprintf(stdout, "memory allocation error for *name in lsfit()\n"); exit(1); } xyzfit = (CORD *) malloc(sizeof(CORD) * (n +10)); if (xyzfit == NULL) { fprintf(stdout, "memory allocation error for *name in lsfit()\n"); exit(1); } ssum=0.; for(i=0;i1000) goto a70; iy=ix+1; if(iy==4) iy=1; iz=6-ix-iy; sig=aa[iz-1][iy-1]-aa[iy-1][iz-1]; gam=aa[iy-1][iy-1]+aa[iz-1][iz-1]; sg=sqrt(sig*sig+gam*gam); if(sg==0) goto a50; sg=1.0/sg; if(fabs(sig)