#include /* compute the length for one dimension*/ int length(int N, int i, double *scf, double *ap, double D, int Nvari) { int maxfactor(int n); double temp1, temp2; int n, j, k, nmax; int nlimit = 13; if (N == 1) { n = 1; } else { for (k = 0; k < Nvari; k++) { temp1 = fabs(ap[9*k+i])*scf[3*k]*scf[3*k]; for (j = 1; j <3; j++) { temp2 = fabs(ap[9*k+3*j+i])*scf[3*k+j]*scf[3*k+j]; if (temp2 > temp1) temp1 = temp2; } } temp1 = sqrt(temp1); temp1 /= (double)D; if ((double)N/temp1 < 2.) { n = N+(int)(2*temp1); } else { n = N+(int)temp1; } if ((n % 2) != 0) n = n+1; nmax = maxfactor(n); while (nmax > nlimit) { n += 2; nmax = maxfactor(n); } } return (n); }