// \Delta x = b void fastpoisson(double *b, double *x, int N) { int i, j; double h, h2, *lamda, *temp, *tempb; tempb = (double *) malloc(N*N*sizeof(double)); temp = (double *) malloc(N*sizeof(double)); lamda = (double *) malloc(N*sizeof(double)); h = 1.0/(N+1); h2 = h*h; for(i=0; i<N*N; i++) tempb[i] = b[i]; for(i=0; i<N; i++) { lamda[i] = 2 - 2*cos((i+1)*M_PI*h); } for (i=0; i<N; i++) { for (j=0; j<N; j++) temp[j] = tempb[N*i+j]; fdst(temp, N); for (j=0; j<N; j++) tempb[N*i+j] = temp[j]; } for (i=0; i<N; i++) { for (j=0; j<N; j++) temp[j] = tempb[N*j+i]; fdst(temp, N); for (j=0; j<N; j++) tempb[N*j+i] = temp[j]; } for(i=0; i<N; i++) { for(j=0; j<N; j++) { x[N*i+j] = -1.0*h2*tempb[N*i+j]/(lamda[i] + lamda[j]); } } for (i=0; i<N; i++) { for (j=0; j<N; j++) temp[j] = x[N*i+j]; fdst(temp, N); for (j=0; j<N; j++) x[N*i+j] = temp[j]; } for (i=0; i<N; i++) { for (j=0; j<N; j++) temp[j] = x[N*j+i]; fdst(temp, N); for (j=0; j<N; j++) x[N*j+i] = temp[j]; } }
bool FileStream::copyFile(const char* srcPath, const char* dstPath) { FileStream fsrc(srcPath, "rb"); FileStream fdst(dstPath, "wb+"); if (fsrc && fdst) { setvbuf(fsrc.fp(), NULL, _IONBF, 0); setvbuf(fdst.fp(), NULL, _IONBF, 0); size_t nbuf = 64 * 1024; AutoFree<char> pbuf(nbuf); while (!fsrc.eof()) { size_t nRead = fsrc.read(pbuf, nbuf); size_t nWrite = fdst.write(pbuf, nRead); if (nWrite != nRead) { throw OutOfSpaceException(BOOST_CURRENT_FUNCTION); } } return true; } return false; }