Changeset 577 in Sophya for trunk/Poubelle/archTOI.old/nrutil.c


Ignore:
Timestamp:
Nov 16, 1999, 2:20:39 PM (26 years ago)
Author:
ansari
Message:

SST

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Poubelle/archTOI.old/nrutil.c

    r556 r577  
    1818}*/
    1919
    20 float *vector(long nl, long nh)
    21 /* allocate a float vector with subscript range v[nl..nh] */
    22 {
    23         float *v;
    24 
    25         v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
     20double *vector(long nl, long nh)
     21/* allocate a double vector with subscript range v[nl..nh] */
     22{
     23        double *v;
     24
     25        v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
    2626        if (!v) nrerror("allocation failure in vector()");
    2727        return v-nl+NR_END;
     
    6868}
    6969
    70 float **matrix(long nrl, long nrh, long ncl, long nch)
    71 /* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
    72 {
    73         long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
    74         float **m;
    75 
    76         /* allocate pointers to rows */
    77         m=(float **) malloc((size_t)((nrow+NR_END)*sizeof(float*)));
    78         if (!m) nrerror("allocation failure 1 in matrix()");
    79         m += NR_END;
    80         m -= nrl;
    81 
    82         /* allocate rows and set pointers to them */
    83         m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float)));
    84         if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
    85         m[nrl] += NR_END;
    86         m[nrl] -= ncl;
    87 
    88         for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
    89 
    90         /* return pointer to array of pointers to rows */
    91         return m;
    92 }
    93 
    94 double **dmatrix(long nrl, long nrh, long ncl, long nch)
     70double **matrix(long nrl, long nrh, long ncl, long nch)
    9571/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
    9672{
     
    11692}
    11793
     94double **dmatrix(long nrl, long nrh, long ncl, long nch)
     95/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
     96{
     97        long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
     98        double **m;
     99
     100        /* allocate pointers to rows */
     101        m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*)));
     102        if (!m) nrerror("allocation failure 1 in matrix()");
     103        m += NR_END;
     104        m -= nrl;
     105
     106        /* allocate rows and set pointers to them */
     107        m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
     108        if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
     109        m[nrl] += NR_END;
     110        m[nrl] -= ncl;
     111
     112        for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
     113
     114        /* return pointer to array of pointers to rows */
     115        return m;
     116}
     117
    118118int **imatrix(long nrl, long nrh, long ncl, long nch)
    119119/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
     
    141141}
    142142
    143 float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
     143double **submatrix(double **a, long oldrl, long oldrh, long oldcl, long oldch,
    144144        long newrl, long newcl)
    145145/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
    146146{
    147147        long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
    148         float **m;
     148        double **m;
    149149
    150150        /* allocate array of pointers to rows */
    151         m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
     151        m=(double **) malloc((size_t) ((nrow+NR_END)*sizeof(double*)));
    152152        if (!m) nrerror("allocation failure in submatrix()");
    153153        m += NR_END;
     
    161161}
    162162
    163 float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch)
    164 /* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
     163double **convert_matrix(double *a, long nrl, long nrh, long ncl, long nch)
     164/* allocate a double matrix m[nrl..nrh][ncl..nch] that points to the matrix
    165165declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
    166166and ncol=nch-ncl+1. The routine should be called with the address
     
    168168{
    169169        long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
    170         float **m;
    171 
    172         /* allocate pointers to rows */
    173         m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
     170        double **m;
     171
     172        /* allocate pointers to rows */
     173        m=(double **) malloc((size_t) ((nrow+NR_END)*sizeof(double*)));
    174174        if (!m) nrerror("allocation failure in convert_matrix()");
    175175        m += NR_END;
     
    183183}
    184184
    185 float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
    186 /* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
     185double ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
     186/* allocate a double 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
    187187{
    188188        long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
    189         float ***t;
     189        double ***t;
    190190
    191191        /* allocate pointers to pointers to rows */
    192         t=(float ***) malloc((size_t)((nrow+NR_END)*sizeof(float**)));
     192        t=(double ***) malloc((size_t)((nrow+NR_END)*sizeof(double**)));
    193193        if (!t) nrerror("allocation failure 1 in f3tensor()");
    194194        t += NR_END;
     
    196196
    197197        /* allocate pointers to rows and set pointers to them */
    198         t[nrl]=(float **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*)));
     198        t[nrl]=(double **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double*)));
    199199        if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
    200200        t[nrl] += NR_END;
     
    202202
    203203        /* allocate rows and set pointers to them */
    204         t[nrl][ncl]=(float *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float)));
     204        t[nrl][ncl]=(double *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(double)));
    205205        if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
    206206        t[nrl][ncl] += NR_END;
     
    218218}
    219219
    220 void free_vector(float *v, long nl, long nh)
    221 /* free a float vector allocated with vector() */
     220void free_vector(double *v, long nl, long nh)
     221/* free a double vector allocated with vector() */
    222222{
    223223        free((FREE_ARG) (v+nl-NR_END));
     
    248248}
    249249
    250 void free_matrix(float **m, long nrl, long nrh, long ncl, long nch)
    251 /* free a float matrix allocated by matrix() */
     250void free_matrix(double **m, long nrl, long nrh, long ncl, long nch)
     251/* free a double matrix allocated by matrix() */
    252252{
    253253        free((FREE_ARG) (m[nrl]+ncl-NR_END));
     
    269269}
    270270
    271 void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch)
     271void free_submatrix(double **b, long nrl, long nrh, long ncl, long nch)
    272272/* free a submatrix allocated by submatrix() */
    273273{
     
    275275}
    276276
    277 void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch)
     277void free_convert_matrix(double **b, long nrl, long nrh, long ncl, long nch)
    278278/* free a matrix allocated by convert_matrix() */
    279279{
     
    281281}
    282282
    283 void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
     283void free_f3tensor(double ***t, long nrl, long nrh, long ncl, long nch,
    284284        long ndl, long ndh)
    285 /* free a float f3tensor allocated by f3tensor() */
     285/* free a double f3tensor allocated by f3tensor() */
    286286{
    287287        free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
     
    309309}
    310310
    311 float *vector(nl,nh)
    312 long nh,nl;
    313 /* allocate a float vector with subscript range v[nl..nh] */
    314 {
    315         float *v;
    316 
    317         v=(float *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(float)));
     311double *vector(nl,nh)
     312long nh,nl;
     313/* allocate a double vector with subscript range v[nl..nh] */
     314{
     315        double *v;
     316
     317        v=(double *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(double)));
    318318        if (!v) nrerror("allocation failure in vector()");
    319319        return v-nl+NR_END;
     
    364364}
    365365
    366 float **matrix(nrl,nrh,ncl,nch)
    367 long nch,ncl,nrh,nrl;
    368 /* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
    369 {
    370         long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
    371         float **m;
    372 
    373         /* allocate pointers to rows */
    374         m=(float **) malloc((unsigned int)((nrow+NR_END)*sizeof(float*)));
    375         if (!m) nrerror("allocation failure 1 in matrix()");
    376         m += NR_END;
    377         m -= nrl;
    378 
    379         /* allocate rows and set pointers to them */
    380         m[nrl]=(float *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float)));
    381         if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
    382         m[nrl] += NR_END;
    383         m[nrl] -= ncl;
    384 
    385         for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
    386 
    387         /* return pointer to array of pointers to rows */
    388         return m;
    389 }
    390 
    391 double **dmatrix(nrl,nrh,ncl,nch)
     366double **matrix(nrl,nrh,ncl,nch)
    392367long nch,ncl,nrh,nrl;
    393368/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
     
    414389}
    415390
     391double **dmatrix(nrl,nrh,ncl,nch)
     392long nch,ncl,nrh,nrl;
     393/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
     394{
     395        long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
     396        double **m;
     397
     398        /* allocate pointers to rows */
     399        m=(double **) malloc((unsigned int)((nrow+NR_END)*sizeof(double*)));
     400        if (!m) nrerror("allocation failure 1 in matrix()");
     401        m += NR_END;
     402        m -= nrl;
     403
     404        /* allocate rows and set pointers to them */
     405        m[nrl]=(double *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double)));
     406        if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
     407        m[nrl] += NR_END;
     408        m[nrl] -= ncl;
     409
     410        for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
     411
     412        /* return pointer to array of pointers to rows */
     413        return m;
     414}
     415
    416416int **imatrix(nrl,nrh,ncl,nch)
    417417long nch,ncl,nrh,nrl;
     
    440440}
    441441
    442 float **submatrix(a,oldrl,oldrh,oldcl,oldch,newrl,newcl)
    443 float **a;
     442double **submatrix(a,oldrl,oldrh,oldcl,oldch,newrl,newcl)
     443double **a;
    444444long newcl,newrl,oldch,oldcl,oldrh,oldrl;
    445445/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
    446446{
    447447        long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
    448         float **m;
     448        double **m;
    449449
    450450        /* allocate array of pointers to rows */
    451         m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
     451        m=(double **) malloc((unsigned int) ((nrow+NR_END)*sizeof(double*)));
    452452        if (!m) nrerror("allocation failure in submatrix()");
    453453        m += NR_END;
     
    461461}
    462462
    463 float **convert_matrix(a,nrl,nrh,ncl,nch)
    464 float *a;
    465 long nch,ncl,nrh,nrl;
    466 /* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
     463double **convert_matrix(a,nrl,nrh,ncl,nch)
     464double *a;
     465long nch,ncl,nrh,nrl;
     466/* allocate a double matrix m[nrl..nrh][ncl..nch] that points to the matrix
    467467declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
    468468and ncol=nch-ncl+1. The routine should be called with the address
     
    470470{
    471471        long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
    472         float **m;
    473 
    474         /* allocate pointers to rows */
    475         m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
     472        double **m;
     473
     474        /* allocate pointers to rows */
     475        m=(double **) malloc((unsigned int) ((nrow+NR_END)*sizeof(double*)));
    476476        if (!m) nrerror("allocation failure in convert_matrix()");
    477477        m += NR_END;
     
    485485}
    486486
    487 float ***f3tensor(nrl,nrh,ncl,nch,ndl,ndh)
     487double ***f3tensor(nrl,nrh,ncl,nch,ndl,ndh)
    488488long nch,ncl,ndh,ndl,nrh,nrl;
    489 /* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
     489/* allocate a double 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
    490490{
    491491        long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
    492         float ***t;
     492        double ***t;
    493493
    494494        /* allocate pointers to pointers to rows */
    495         t=(float ***) malloc((unsigned int)((nrow+NR_END)*sizeof(float**)));
     495        t=(double ***) malloc((unsigned int)((nrow+NR_END)*sizeof(double**)));
    496496        if (!t) nrerror("allocation failure 1 in f3tensor()");
    497497        t += NR_END;
     
    499499
    500500        /* allocate pointers to rows and set pointers to them */
    501         t[nrl]=(float **) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float*)));
     501        t[nrl]=(double **) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double*)));
    502502        if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
    503503        t[nrl] += NR_END;
     
    505505
    506506        /* allocate rows and set pointers to them */
    507         t[nrl][ncl]=(float *) malloc((unsigned int)((nrow*ncol*ndep+NR_END)*sizeof(float)));
     507        t[nrl][ncl]=(double *) malloc((unsigned int)((nrow*ncol*ndep+NR_END)*sizeof(double)));
    508508        if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
    509509        t[nrl][ncl] += NR_END;
     
    522522
    523523void free_vector(v,nl,nh)
    524 float *v;
    525 long nh,nl;
    526 /* free a float vector allocated with vector() */
     524double *v;
     525long nh,nl;
     526/* free a double vector allocated with vector() */
    527527{
    528528        free((FREE_ARG) (v+nl-NR_END));
     
    562562
    563563void free_matrix(m,nrl,nrh,ncl,nch)
    564 float **m;
    565 long nch,ncl,nrh,nrl;
    566 /* free a float matrix allocated by matrix() */
     564double **m;
     565long nch,ncl,nrh,nrl;
     566/* free a double matrix allocated by matrix() */
    567567{
    568568        free((FREE_ARG) (m[nrl]+ncl-NR_END));
     
    589589
    590590void free_submatrix(b,nrl,nrh,ncl,nch)
    591 float **b;
     591double **b;
    592592long nch,ncl,nrh,nrl;
    593593/* free a submatrix allocated by submatrix() */
     
    597597
    598598void free_convert_matrix(b,nrl,nrh,ncl,nch)
    599 float **b;
     599double **b;
    600600long nch,ncl,nrh,nrl;
    601601/* free a matrix allocated by convert_matrix() */
     
    605605
    606606void free_f3tensor(t,nrl,nrh,ncl,nch,ndl,ndh)
    607 float ***t;
     607double ***t;
    608608long nch,ncl,ndh,ndl,nrh,nrl;
    609 /* free a float f3tensor allocated by f3tensor() */
     609/* free a double f3tensor allocated by f3tensor() */
    610610{
    611611        free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
Note: See TracChangeset for help on using the changeset viewer.