#include "hc.h" /* miscellaneous functions for allocating arrays, copying arrays, opening file streams, the like $Id: hc_misc.c,v 1.5 2004/12/20 05:18:12 becker Exp becker $ */ /* double vector allocation */ void hc_dvecalloc(double **x,int n,char *message) { *x = (double *)malloc(sizeof(double)*(size_t)n); if(! (*x)) HC_MEMERROR(message); } /* single prec vector allocation */ void hc_svecalloc(float **x,int n,char *message) { *x = (float *)malloc(sizeof(float)*(size_t)n); if(! (*x)) HC_MEMERROR(message); } /* general floating point vector allocation */ void hc_vecalloc(HC_PREC **x,int n,char *message) { *x = (HC_PREC *)malloc(sizeof(HC_PREC)*(size_t)n); if(! (*x)) HC_MEMERROR(message); } /* single prec complex vector allocation */ void hc_scmplx_vecalloc(struct hc_scmplx **x,int n,char *message) { *x = (struct hc_scmplx *)malloc(sizeof(struct hc_scmplx)*(size_t)n); if(! (*x)) HC_MEMERROR(message); } /* single vector reallocation */ void hc_svecrealloc(float **x,int n,char *message) { *x = (float *)realloc(*x,sizeof(float)*(size_t)n); if(!(*x)) HC_MEMERROR(message); } /* double vector reallocation */ void hc_dvecrealloc(double **x,int n,char *message) { *x = (double *)realloc(*x,sizeof(double)*(size_t)n); if(!(*x)) HC_MEMERROR(message); } /* general version */ void hc_vecrealloc(HC_PREC **x,int n,char *message) { *x = (HC_PREC *)realloc(*x,sizeof(HC_PREC)*(size_t)n); if(!(*x)) HC_MEMERROR(message); } /* sqrt(sum(squared diff)) between [n] vectors a and b */ float hc_svec_rms_diff(float *a,float *b,int n) { int i; float sum=0.0,tmp; for(i=0;ilmax,g1->lmax); lmaxg = MIN(20,lmaxg); switch(mode){ case 0: if(verbose) fprintf(stderr,"hc_compute_correlation: computing 1...%i\n",lmaxg); c[0] = sh_correlation_per_degree(g1,g2,1,lmaxg); case 1: /* 1...20 and 4..9 correlations */ if(verbose) fprintf(stderr,"hc_compute_correlation: computing 1...%i and 4..9 correlations\n",lmaxg); c[0] = sh_correlation_per_degree(g1,g2,1,lmaxg); c[1] = sh_correlation_per_degree(g1,g2,4,9); break; default: fprintf(stderr,"sh_compute_correlation: mode %i undefined\n",mode); exit(-1); } }