void solveVp(int rank,struct poisson* thePoisson){ int i,j,k; int N_r_glob=thePoisson->N_r_glob; int N_k=thePoisson->N_k; int N_z_glob=thePoisson->N_z_glob; double * D_buf=thePoisson->shortbuffer; double * data=thePoisson->density; double n; double *V_buf=(double *)malloc(sizeof(double)*N_r_glob); for(j=0;j<N_k;j++){ n=thePoisson->freq[thePoisson->k_start+j]; for(k=0;k<N_z_glob;k++){ for(i=0;i<N_r_glob;i++){ double lamba=1.0/(2*(i+1)-1); thePoisson->a[i]=thePoisson->eigenvalues[k]-4.0*pow(n,2)*pow(lamba,2); thePoisson->b[i]=1.0+1.0/(2*(i+1)-1); thePoisson->c[i]=1.0-1.0/(2*(i+1)-1); D_buf[i]=data[in_lookup(thePoisson,k,i,j)]; } solvetridiag(thePoisson->a,thePoisson->b,thePoisson->c,D_buf,V_buf,N_r_glob); for(i=0;i<N_r_glob;i++) data[in_lookup(thePoisson,k,i,j)]=V_buf[i]; } } free(V_buf); }
int innetgr(const char *grp, const char *host, const char *user, const char *domain) { char *ypdom = NULL, *grpdup; #ifdef YP char *line = NULL; #endif int found; struct stringlist *sl; if (_ng_db == NULL) _ng_db = dbopen(_PATH_NETGROUP_DB, O_RDONLY, 0, DB_HASH, NULL); #ifdef YP /* * We use yp if there is a "+" in the netgroup file, or if there is * no netgroup file at all */ if (_ng_db == NULL) yp_get_default_domain(&ypdom); else if (lookup(NULL, "+", &line, _NG_KEYBYNAME) == 0) yp_get_default_domain(&ypdom); if (line) free(line); #endif /* Try the fast lookup first */ if (host != NULL && user == NULL) { if (in_lookup(ypdom, grp, host, domain, _NG_KEYBYHOST)) return 1; } else if (host == NULL && user != NULL) { if (in_lookup(ypdom, grp, user, domain, _NG_KEYBYUSER)) return 1; } /* If a domainname is given, we would have found a match */ if (domain != NULL) return 0; grpdup = strdup(grp); if (grpdup == NULL) return 0; /* Too bad need the slow recursive way */ sl = _ng_sl_init(); if (sl == NULL) { free(grpdup); return 0; } found = in_find(ypdom, sl, grpdup, host, user, domain); _ng_sl_free(sl, 1); return found; }
void sinefft(struct poisson* thePoisson){ int i,j,k; double *in=thePoisson->density; const int N_element=thePoisson->N_z_glob; int N_k=thePoisson->N_k; int N_r_glob=thePoisson->N_r_glob; int N_z_glob=thePoisson->N_z_glob; const double uni=sqrt(0.5*(N_element+1)); /* double * sine_buf=thePoisson->shortbuffer; fftw_plan p; for(j=0;j<N_k;j++) for(i=0;i<N_r_glob;i++){ for(k=0;k<N_z_glob;k++) sine_buf[k]=in[in_lookup(thePoisson,k,i,j)]; p=fftw_plan_r2r_1d(N_element, sine_buf,sine_buf,FFTW_RODFT00,FFTW_ESTIMATE); fftw_execute(p); for(k=0;k<N_z_glob;k++) in[in_lookup(thePoisson,k,i,j)]=sine_buf[k]/2.0/uni; fftw_destroy_plan(p); } */ double * sine_buf=thePoisson->buffer; int idx=0; for(j=0;j<N_k;j++) for(i=0;i<N_r_glob;i++) for(k=0;k<N_z_glob;k++) sine_buf[idx++]=in[in_lookup(thePoisson,k,i,j)]; const int n[1]={N_element}; const fftw_r2r_kind kind[1]={FFTW_RODFT00}; fftw_plan p=fftw_plan_many_r2r(1,n,N_k*N_r_glob,sine_buf,n,1,N_element,sine_buf,n,1,N_element,kind,FFTW_ESTIMATE); fftw_execute(p); fftw_destroy_plan(p); idx=0; i=0;j=0;k=0; for(j=0;j<N_k;j++) for(i=0;i<N_z_glob;i++) for(k=0;k<N_z_glob;k++) in[in_lookup(thePoisson,k,i,j)]=sine_buf[idx++]/2.0/uni; fftw_cleanup(); //nnote: in and out should have the same size;same size after sine transform }
int main() { vll lookup_5; for(long long i=1; i<1.5*CUTOFF; i++) lookup_5.push_back(i*i*i*i*i); for(long long a=1; a<CUTOFF; a++) { for(long long b=a; b<CUTOFF; b++) { std::cout << "a:" << a << " b:" << b << '\n'; for(long long c=b; c<CUTOFF; c++) { for(long long d=c; d<CUTOFF; d++) { long long e5 = a*a*a*a*a + b*b*b*b*b + c*c*c*c*c + d*d*d*d*d; if (in_lookup(lookup_5, e5)) { std::cout<<a<<"^5 + "<<b<<"^5 + "<<c<< "^5 + "<<d<<"^5 = "<< int(pow(e5, 0.2)) << "^5"; goto stop; } } } } } stop: return 0; }