- #include <stdlib.h>
- #include <stdio.h>
- #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 */
- if (!m) nrerror("allocation failure 1 in matrix()");
- m += NR_END;
- m -= nrl;
- /* allocate rows and set pointers to them */
- 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 */
- if (!m) nrerror("allocation failure 1 in matrix()");
- m += NR_END;
- m -= nrl;
- /* allocate rows and set pointers to them */
- 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() */
- {
- }
- void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch)
- /* free an int matrix allocated by imatrix() */
- {
- }
- void nrerror(char error_text[])
- /* Numerical Recipes standard error handler */
- {
- }
Raw Paste