DAS  3.1.6 - 18/09/2017
Macros | Functions
NRUTIL.C File Reference
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
+ Include dependency graph for NRUTIL.C:

Go to the source code of this file.

Macros

#define FREE_ARG   char*
 
#define NR_END   1
 

Functions

float ** convert_matrix (float *a, long nrl, long nrh, long ncl, long nch)
 
unsigned char * cvector (long nl, long nh)
 
double ** dmatrix (long nrl, long nrh, long ncl, long nch)
 
double * dvector (long nl, long nh)
 
float *** f3tensor (long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
 
void free_convert_matrix (float **b, long nrl, long nrh, long ncl, long nch)
 
void free_cvector (unsigned char *v, long nl, long nh)
 
void free_dmatrix (double **m, long nrl, long nrh, long ncl, long nch)
 
void free_dvector (double *v, long nl, long nh)
 
void free_f3tensor (float ***t, long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
 
void free_imatrix (int **m, long nrl, long nrh, long ncl, long nch)
 
void free_ivector (int *v, long nl, long nh)
 
void free_lvector (unsigned long *v, long nl, long nh)
 
void free_matrix (float **m, long nrl, long nrh, long ncl, long nch)
 
void free_submatrix (float **b, long nrl, long nrh, long ncl, long nch)
 
void free_vector (float *v, long nl, long nh)
 
int ** imatrix (long nrl, long nrh, long ncl, long nch)
 
int * ivector (long nl, long nh)
 
unsigned long * lvector (long nl, long nh)
 
float ** matrix (long nrl, long nrh, long ncl, long nch)
 
void nrerror (error_text)
 
float ** submatrix (float **a, long oldrl, long oldrh, long oldcl, long oldch, long newrl, long newcl)
 
float * vector (long nl, long nh)
 

Macro Definition Documentation

§ FREE_ARG

#define FREE_ARG   char*

§ NR_END

#define NR_END   1

Function Documentation

§ convert_matrix()

float** convert_matrix ( float *  a,
long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 469 of file NRUTIL.C.

References NR_END, and nrerror().

476 {
477  long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
478  float **m;
479 
480  /* allocate pointers to rows */
481  m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
482  if (!m) nrerror("allocation failure in convert_matrix()");
483  m += NR_END;
484  m -= nrl;
485 
486  /* set pointers to rows */
487  m[nrl]=a-ncl;
488  for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
489  /* return pointer to array of pointers to rows */
490  return m;
491 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ cvector()

unsigned char* cvector ( long  nl,
long  nh 
)

Definition at line 339 of file NRUTIL.C.

References NR_END, and nrerror().

342 {
343  unsigned char *v;
344 
345  v=(unsigned char *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
346  if (!v) nrerror("allocation failure in cvector()");
347  return v-nl+NR_END;
348 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ dmatrix()

double** dmatrix ( long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 397 of file NRUTIL.C.

References NR_END, and nrerror().

400 {
401  long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
402  double **m;
403 
404  /* allocate pointers to rows */
405  m=(double **) malloc((unsigned int)((nrow+NR_END)*sizeof(double*)));
406  if (!m) nrerror("allocation failure 1 in matrix()");
407  m += NR_END;
408  m -= nrl;
409 
410  /* allocate rows and set pointers to them */
411  m[nrl]=(double *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double)));
412  if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
413  m[nrl] += NR_END;
414  m[nrl] -= ncl;
415 
416  for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
417 
418  /* return pointer to array of pointers to rows */
419  return m;
420 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ dvector()

double* dvector ( long  nl,
long  nh 
)

Definition at line 361 of file NRUTIL.C.

References NR_END, and nrerror().

364 {
365  double *v;
366 
367  v=(double *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(double)));
368  if (!v) nrerror("allocation failure in dvector()");
369  return v-nl+NR_END;
370 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ f3tensor()

float*** f3tensor ( long  nrl,
long  nrh,
long  ncl,
long  nch,
long  ndl,
long  ndh 
)

Definition at line 493 of file NRUTIL.C.

References NR_END, and nrerror().

496 {
497  long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
498  float ***t;
499 
500  /* allocate pointers to pointers to rows */
501  t=(float ***) malloc((unsigned int)((nrow+NR_END)*sizeof(float**)));
502  if (!t) nrerror("allocation failure 1 in f3tensor()");
503  t += NR_END;
504  t -= nrl;
505 
506  /* allocate pointers to rows and set pointers to them */
507  t[nrl]=(float **) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float*)));
508  if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
509  t[nrl] += NR_END;
510  t[nrl] -= ncl;
511 
512  /* allocate rows and set pointers to them */
513  t[nrl][ncl]=(float *) malloc((unsigned int)((nrow*ncol*ndep+NR_END)*sizeof(float)));
514  if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
515  t[nrl][ncl] += NR_END;
516  t[nrl][ncl] -= ndl;
517 
518  for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
519  for(i=nrl+1;i<=nrh;i++) {
520  t[i]=t[i-1]+ncol;
521  t[i][ncl]=t[i-1][ncl]+ncol*ndep;
522  for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
523  }
524 
525  /* return pointer to array of pointers to rows */
526  return t;
527 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ free_convert_matrix()

void free_convert_matrix ( float **  b,
long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 604 of file NRUTIL.C.

References FREE_ARG, and NR_END.

608 {
609  free((FREE_ARG) (b+nrl-NR_END));
610 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_cvector()

void free_cvector ( unsigned char *  v,
long  nl,
long  nh 
)

Definition at line 545 of file NRUTIL.C.

References FREE_ARG, and NR_END.

549 {
550  free((FREE_ARG) (v+nl-NR_END));
551 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_dmatrix()

void free_dmatrix ( double **  m,
long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 578 of file NRUTIL.C.

References FREE_ARG, and NR_END.

582 {
583  free((FREE_ARG) (m[nrl]+ncl-NR_END));
584  free((FREE_ARG) (m+nrl-NR_END));
585 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_dvector()

void free_dvector ( double *  v,
long  nl,
long  nh 
)

Definition at line 561 of file NRUTIL.C.

References FREE_ARG, and NR_END.

565 {
566  free((FREE_ARG) (v+nl-NR_END));
567 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_f3tensor()

void free_f3tensor ( float ***  t,
long  nrl,
long  nrh,
long  ncl,
long  nch,
long  ndl,
long  ndh 
)

Definition at line 612 of file NRUTIL.C.

References FREE_ARG, and NR_END.

616 {
617  free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
618  free((FREE_ARG) (t[nrl]+ncl-NR_END));
619  free((FREE_ARG) (t+nrl-NR_END));
620 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_imatrix()

void free_imatrix ( int **  m,
long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 587 of file NRUTIL.C.

References FREE_ARG, and NR_END.

591 {
592  free((FREE_ARG) (m[nrl]+ncl-NR_END));
593  free((FREE_ARG) (m+nrl-NR_END));
594 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_ivector()

void free_ivector ( int *  v,
long  nl,
long  nh 
)

Definition at line 537 of file NRUTIL.C.

References FREE_ARG, and NR_END.

541 {
542  free((FREE_ARG) (v+nl-NR_END));
543 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_lvector()

void free_lvector ( unsigned long *  v,
long  nl,
long  nh 
)

Definition at line 553 of file NRUTIL.C.

References FREE_ARG, and NR_END.

557 {
558  free((FREE_ARG) (v+nl-NR_END));
559 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_matrix()

void free_matrix ( float **  m,
long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 569 of file NRUTIL.C.

References FREE_ARG, and NR_END.

573 {
574  free((FREE_ARG) (m[nrl]+ncl-NR_END));
575  free((FREE_ARG) (m+nrl-NR_END));
576 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_submatrix()

void free_submatrix ( float **  b,
long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 596 of file NRUTIL.C.

References FREE_ARG, and NR_END.

600 {
601  free((FREE_ARG) (b+nrl-NR_END));
602 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ free_vector()

void free_vector ( float *  v,
long  nl,
long  nh 
)

Definition at line 529 of file NRUTIL.C.

References FREE_ARG, and NR_END.

533 {
534  free((FREE_ARG) (v+nl-NR_END));
535 }
#define FREE_ARG
Definition: NRUTIL.C:303
#define NR_END
Definition: NRUTIL.C:302

§ imatrix()

int** imatrix ( long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 422 of file NRUTIL.C.

References NR_END, and nrerror().

425 {
426  long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
427  int **m;
428 
429  /* allocate pointers to rows */
430  m=(int **) malloc((unsigned int)((nrow+NR_END)*sizeof(int*)));
431  if (!m) nrerror("allocation failure 1 in matrix()");
432  m += NR_END;
433  m -= nrl;
434 
435 
436  /* allocate rows and set pointers to them */
437  m[nrl]=(int *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(int)));
438  if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
439  m[nrl] += NR_END;
440  m[nrl] -= ncl;
441 
442  for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
443 
444  /* return pointer to array of pointers to rows */
445  return m;
446 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ ivector()

int* ivector ( long  nl,
long  nh 
)

Definition at line 328 of file NRUTIL.C.

References NR_END, and nrerror().

331 {
332  int *v;
333 
334  v=(int *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(int)));
335  if (!v) nrerror("allocation failure in ivector()");
336  return v-nl+NR_END;
337 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ lvector()

unsigned long* lvector ( long  nl,
long  nh 
)

Definition at line 350 of file NRUTIL.C.

References NR_END, and nrerror().

353 {
354  unsigned long *v;
355 
356  v=(unsigned long *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(long)));
357  if (!v) nrerror("allocation failure in lvector()");
358  return v-nl+NR_END;
359 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ matrix()

float** matrix ( long  nrl,
long  nrh,
long  ncl,
long  nch 
)

Definition at line 372 of file NRUTIL.C.

References NR_END, and nrerror().

375 {
376  long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
377  float **m;
378 
379  /* allocate pointers to rows */
380  m=(float **) malloc((unsigned int)((nrow+NR_END)*sizeof(float*)));
381  if (!m) nrerror("allocation failure 1 in matrix()");
382  m += NR_END;
383  m -= nrl;
384 
385  /* allocate rows and set pointers to them */
386  m[nrl]=(float *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float)));
387  if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
388  m[nrl] += NR_END;
389  m[nrl] -= ncl;
390 
391  for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
392 
393  /* return pointer to array of pointers to rows */
394  return m;
395 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ nrerror()

void nrerror ( error_text  )

Definition at line 305 of file NRUTIL.C.

Referenced by convert_matrix(), cvector(), dmatrix(), dvector(), f3tensor(), imatrix(), ivector(), lvector(), matrix(), submatrix(), and vector().

308 {
309  void exit();
310 
311  fprintf(stderr,"Numerical Recipes run-time error...\n");
312  fprintf(stderr,"%s\n",error_text);
313  fprintf(stderr,"...now exiting to system...\n");
314  exit(1);
315 }
+ Here is the caller graph for this function:

§ submatrix()

float** submatrix ( float **  a,
long  oldrl,
long  oldrh,
long  oldcl,
long  oldch,
long  newrl,
long  newcl 
)

Definition at line 448 of file NRUTIL.C.

References NR_END, and nrerror().

452 {
453  long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
454  float **m;
455 
456  /* allocate array of pointers to rows */
457  m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
458  if (!m) nrerror("allocation failure in submatrix()");
459  m += NR_END;
460  m -= newrl;
461 
462  /* set pointers to rows */
463  for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
464 
465  /* return pointer to array of pointers to rows */
466  return m;
467 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:

§ vector()

float* vector ( long  nl,
long  nh 
)

Definition at line 317 of file NRUTIL.C.

References NR_END, and nrerror().

320 {
321  float *v;
322 
323  v=(float *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(float)));
324  if (!v) nrerror("allocation failure in vector()");
325  return v-nl+NR_END;
326 }
void nrerror(error_text)
Definition: NRUTIL.C:305
#define NR_END
Definition: NRUTIL.C:302
+ Here is the call graph for this function:
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:46:35 for DAS - Rel. 3.1.6 - 18/09/2017.