From: W. Trevor King Date: Tue, 14 Sep 2010 19:02:16 +0000 (-0400) Subject: Consolidate Numerical Recipes code into src/NR/. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b25a234d4de9cd7b6adf0bbac7beb95ee9f9ba0d;p=parallel_computing.git Consolidate Numerical Recipes code into src/NR/. --- diff --git a/src/poisson_SOR/possibly_old/NR.c b/src/NR/NR.c similarity index 100% rename from src/poisson_SOR/possibly_old/NR.c rename to src/NR/NR.c diff --git a/src/poisson_SOR/possibly_old/NR.h b/src/NR/NR.h similarity index 100% rename from src/poisson_SOR/possibly_old/NR.h rename to src/NR/NR.h diff --git a/src/poisson_2d/NR b/src/poisson_2d/NR new file mode 120000 index 0000000..0b9009d --- /dev/null +++ b/src/poisson_2d/NR @@ -0,0 +1 @@ +../NR/ \ No newline at end of file diff --git a/src/poisson_2d/NR_utilities.c b/src/poisson_2d/NR_utilities.c deleted file mode 100644 index 9ac1d4b..0000000 --- a/src/poisson_2d/NR_utilities.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - subroutines to allocate & free memory for - double and int matrices with arbitrary - index ranges - - from Numerical Recipies -*/ - -#include -#include - -#define NR_END 1 -#define FREE_ARG char* - -void nrerror(char error_text[]); - -double **dmatrix(long nrl, long nrh, long ncl, long nch) -/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */ -{ - long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; - double **m; - - /* allocate pointers to rows */ - m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*))); - if (!m) nrerror("allocation failure 1 in matrix()"); - m += NR_END; - m -= nrl; - - /* allocate rows and set pointers to them */ - m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double))); - if (!m[nrl]) nrerror("allocation failure 2 in matrix()"); - m[nrl] += NR_END; - m[nrl] -= ncl; - - for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; - - /* return pointer to array of pointers to rows */ - return m; -} - - - -int **imatrix(long nrl, long nrh, long ncl, long nch) -/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */ -{ - long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; - int **m; - - /* allocate pointers to rows */ - m=(int **) malloc((size_t)((nrow+NR_END)*sizeof(int*))); - if (!m) nrerror("allocation failure 1 in matrix()"); - m += NR_END; - m -= nrl; - - - /* allocate rows and set pointers to them */ - m[nrl]=(int *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(int))); - if (!m[nrl]) nrerror("allocation failure 2 in matrix()"); - m[nrl] += NR_END; - m[nrl] -= ncl; - - for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; - - /* return pointer to array of pointers to rows */ - return m; -} - - -void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch) -/* free a double matrix allocated by dmatrix() */ -{ - free((FREE_ARG) (m[nrl]+ncl-NR_END)); - free((FREE_ARG) (m+nrl-NR_END)); -} - - - -void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch) -/* free an int matrix allocated by imatrix() */ -{ - free((FREE_ARG) (m[nrl]+ncl-NR_END)); - free((FREE_ARG) (m+nrl-NR_END)); -} - - -void nrerror(char error_text[]) -/* Numerical Recipes standard error handler */ -{ - fprintf(stderr,"Numerical Recipes run-time error...\n"); - fprintf(stderr,"%s\n",error_text); - fprintf(stderr,"...now exiting to system...\n"); - exit(1); -} diff --git a/src/poisson_SOR/possibly_old/NR b/src/poisson_SOR/possibly_old/NR new file mode 120000 index 0000000..65dd80c --- /dev/null +++ b/src/poisson_SOR/possibly_old/NR @@ -0,0 +1 @@ +../../NR/ \ No newline at end of file