正在加载图片...
Utility Routines (nrutil.c) 945 float **submatrix(float **a,long oldrl,long oldrh,long oldcl,long oldch, long nevrl,long newcl) /point a submatrix [newrl..][newcl..]to a[oldrl..oldrh][oldcl..oldch]* long i,j,nrow=oldrh-oldrl+1,ncolsoldcl-newcl; f10at米*; /allocate array of pointers to rows * m=(float **malloc((size_t)((nrow+NR_END)*sizeof(float*))); if (!m)nrerror("allocation failure in submatrix()"); m+=NR_END: http://www.nr. Permission is read able files m-=newrl; /set pointers to rows * 839 for(i=oldrl,j=newrl;i<=oldrh;i++,j++)m[j]=a[i]+ncol; (including this one) granted for i /return pointer to array of pointers to rows * 11-600 return m; float **convert_matrix(float *a,long nrl,long nrh,long ncl,long nch) to any from NUMERICAL RECIPES IN 19881992 /allocate a float matrix m[nrl..nrh][ncl..nch]that points to the matrix declared in the standard C manner as a[nrow][ncol],where nrow=nrh-nrl+1 and ncol-nch-ncl+1.The routine should be called with the address &a[O][O]as the first argument. (North America server computer, long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1; one paper Cambridge University Press. THE 是 ART f10at米*m; /allocate pointers to rows/ Programs m=(float **malloc((size_t)((nrow+NR_END)*sizeof(float*))); if (!m)nrerror("allocation failure in convert_matrix()"); m+=NR_END; m-nrl; Copyright (C) /set pointers to rows * m[nrl]=a-ncl; for(i=1,j=nrl+1;i<nrow;i++,j++)m[j]=m[j-1]+ncol; to directcustsen OF SCIENTIFIC COMPUTING(ISBN /return pointer to array of pointers to rows return m; v@cambr 1988-1992 by Numerical Recipes 10-621 float ***f3tensor(long nrl,long nrh,long ncl,long nch,long ndl,long ndh) /allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh]*/ 43108 long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1; f10at*来*t; (outside /allocate pointers to pointers to rows * t=(float ***malloc((size_t)((nrow+NR_END)*sizeof(float**))); Software. if (!t)nrerror("allocation failure 1 in f3tensor()"); t+=NR_END; t-=nrl; North America) visit website /allocate pointers to rows and set pointers to them * machine t [nrl]=(float **malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*))); if (!t[nrl])nrerror("allocation failure 2 in f3tensor()"); t [nrl]+NR_END; t[nrl]-ncl; /allocate rows and set pointers to them * t[nrl][ncl]=(float *malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float))); if (!t[nrl][ncl])nrerror("allocation failure 3 in f3tensor()");Utility Routines (nrutil.c) 945 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch, long newrl, long newcl) /* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */ { long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl; float **m; /* allocate array of pointers to rows */ m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*))); if (!m) nrerror("allocation failure in submatrix()"); m += NR_END; m -= newrl; /* set pointers to rows */ for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol; /* return pointer to array of pointers to rows */ return m; } float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch) /* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1 and ncol=nch-ncl+1. The routine should be called with the address &a[0][0] as the first argument. */ { long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1; float **m; /* allocate pointers to rows */ m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*))); if (!m) nrerror("allocation failure in convert_matrix()"); m += NR_END; m -= nrl; /* set pointers to rows */ m[nrl]=a-ncl; for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol; /* return pointer to array of pointers to rows */ return m; } float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh) /* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */ { long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1; float ***t; /* allocate pointers to pointers to rows */ t=(float ***) malloc((size_t)((nrow+NR_END)*sizeof(float**))); if (!t) nrerror("allocation failure 1 in f3tensor()"); t += NR_END; t -= nrl; /* allocate pointers to rows and set pointers to them */ t[nrl]=(float **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*))); if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()"); t[nrl] += NR_END; t[nrl] -= ncl; /* allocate rows and set pointers to them */ t[nrl][ncl]=(float *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float))); if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有