您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vect_free函数代码示例

51自学网 2021-06-03 09:36:48
  C++
这篇教程C++ vect_free函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中vect_free函数的典型用法代码示例。如果您正苦于以下问题:C++ vect_free函数的具体用法?C++ vect_free怎么用?C++ vect_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vect_free函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: vect_strcmp

int vect_strcmp(const vector vector1,const vector vector2){	int ret = 0;	vector vector_temp1;	vector vector_temp2;	if(!vector1 || !vector2) //空指针 出错		return -1;	if(vect_getelmtype(vector1) !=STRING || vect_getelmtype(vector2) !=STRING) //保存的不是字符串 出错		return -1;	if(vect_getlength(vector1) !=vect_getlength(vector2))	//保存的字符串个数不一致 肯定不相等		return 1;		//拷贝副本	vector_temp1=vect_copy(vector1);	if(!vector_temp1)		return -1;	vector_temp2=vect_copy(vector2);	if(!vector_temp2)		return -1;	vect_sortstr(vector_temp1);	vect_sortstr(vector_temp2);	ret = vect_strcmp_order(vector_temp1, vector_temp2);	vect_free(vector_temp1);	vect_free(vector_temp2);	return (ret);}
开发者ID:198767,项目名称:cyy2,代码行数:26,


示例2: determine_padvals

int determine_padvals(char *maskfilenm, mask * obsmask, float *padvals[])/* Determine reasonable padding values from the rfifind produced  *//* *.stats file if it is available.  Return the allocated vector  *//* (of length numchan) in padvals.  Return a '1' if the routine   *//* used the stats file, return 0 if the padding was set to aeros. */{   FILE *statsfile;   int ii, numchan, numint, ptsperint, lobin, numbetween;   float **dataavg, tmp1, tmp2;   char *statsfilenm, *root, *suffix;   if (split_root_suffix(maskfilenm, &root, &suffix) == 0) {      printf("/nThe mask filename (%s) must have a suffix!/n/n", maskfilenm);      exit(1);   } else {      /* Determine the stats file name */      statsfilenm = calloc(strlen(maskfilenm) + 2, sizeof(char));      sprintf(statsfilenm, "%s.stats", root);      free(root);      free(suffix);      *padvals = gen_fvect(obsmask->numchan);      /* Check to see if the file exists */      printf("Attempting to read the data statistics from '%s'.../n", statsfilenm);      statsfile = chkfopen(statsfilenm, "rb");      free(statsfilenm);      if (statsfile) {          /* Read the stats */         chkfread(&numchan, sizeof(int), 1, statsfile);         chkfread(&numint, sizeof(int), 1, statsfile);         chkfread(&ptsperint, sizeof(int), 1, statsfile);         chkfread(&lobin, sizeof(int), 1, statsfile);         chkfread(&numbetween, sizeof(int), 1, statsfile);         dataavg = gen_fmatrix(numint, numchan);         /* These are the powers */         chkfread(dataavg[0], sizeof(float), numchan * numint, statsfile);         /* These are the averages */         chkfread(dataavg[0], sizeof(float), numchan * numint, statsfile);         /* Set the padding values equal to the mid-80% channel averages */         for (ii = 0; ii < numchan; ii++)            calc_avgmedstd(dataavg[0] + ii, numint, 0.8, numchan,                           *padvals + ii, &tmp1, &tmp2);         printf             ("...succeded.  Set the padding values equal to the mid-80%% channel averages./n");         vect_free(dataavg[0]);         vect_free(dataavg);         fclose(statsfile);         return 1;      } else {         /* This is a temporary solution */         for (ii = 0; ii < obsmask->numchan; ii++)            (*padvals)[ii] = 0.0;         printf("...failed./n  Set the padding values to 0./n");         return 0;      }   }}
开发者ID:dlakaplan,项目名称:presto,代码行数:55,


示例3: free_fftpart

static void free_fftpart(fftpart * fp){   vect_free(fp->normvals);   vect_free(fp->medians);   vect_free(fp->rawpowers);#ifdef USEMMAP   munmap(fp->amps, sizeof(fcomplex) * fp->numamps);#else   vect_free(fp->amps);#endif   free(fp);}
开发者ID:bretonr,项目名称:presto,代码行数:12,


示例4: delete_prepfoldinfo

void delete_prepfoldinfo(prepfoldinfo * in)/* Free all dynamic arrays in the prepfold array */{   vect_free(in->rawfolds);   if (in->nsub > 1)      vect_free(in->dms);   vect_free(in->periods);   vect_free(in->pdots);   free(in->stats);   free(in->filenm);   free(in->candnm);   free(in->telescope);   free(in->pgdev);}
开发者ID:bretonr,项目名称:presto,代码行数:14,


示例5: estimate_offpulse_redchi2

float estimate_offpulse_redchi2(double *inprofs, foldstats *stats,                                int numparts, int numsubbands,                                 int proflen, int numtrials, double dofeff)// Randomly offset each pulse profile in a .pfd data square or cube// and combine them to estimate a "true" off-pulse level.  Do this// numtrials times in order to improve the statistics.  Return the// inverse of the average of the off-pulse reduced-chi^2 (i.e. the// correction factor).  dofeff is the effective number of DOF as// returned by DOF_corr().{    int ii, jj, kk, offset, trialnum, phsindex, statindex;    float *chis;    double chi_avg, chi_var, redchi;    double prof_avg, prof_var, *prof_ptr, *sumprof;    sumprof = gen_dvect(proflen);    chis = gen_fvect(numtrials);    for (trialnum = 0; trialnum < numtrials; trialnum++) {        // Initialize the summed profile        for (ii = 0; ii < proflen; ii++)            sumprof[ii] = 0.0;        prof_avg = 0.0;        prof_var = 0.0;        prof_ptr = inprofs;        for (ii = 0; ii < numparts; ii++) {  // parts            for (jj = 0; jj < numsubbands; jj++) {  // subbands                statindex = ii * numsubbands + jj;                offset = random() % proflen;                phsindex = 0;                for (kk = offset; kk < proflen; kk++, phsindex++) // phases                    sumprof[phsindex] += prof_ptr[kk];                for (kk = 0; kk < offset; kk++, phsindex++) // phases                    sumprof[phsindex] += prof_ptr[kk];                prof_ptr += proflen;                prof_avg += stats[statindex].prof_avg;                prof_var += stats[statindex].prof_var;            }        }        /* Calculate the current chi-squared */        redchi = chisqr(sumprof, proflen, prof_avg, prof_var) / dofeff;        chis[trialnum] = (float) redchi;    }    avg_var(chis, numtrials, &chi_avg, &chi_var);    vect_free(chis);    vect_free(sumprof);    return 1.0/chi_avg;}
开发者ID:bretonr,项目名称:presto,代码行数:48,


示例6: write_padding

void write_padding(FILE * outfiles[], int numfiles, float value, int numtowrite){    int ii;    if (numtowrite <= 0) {        return;    } else if (numtowrite == 1) {        for (ii = 0; ii < numfiles; ii++)            chkfwrite(&value, sizeof(float), 1, outfiles[ii]);    } else {        int maxatonce = 8192, veclen, jj;        float *buffer;        veclen = (numtowrite > maxatonce) ? maxatonce : numtowrite;        buffer = gen_fvect(veclen);        for (ii = 0; ii < veclen; ii++)            buffer[ii] = value;        if (veclen == numtowrite) {            for (ii = 0; ii < numfiles; ii++)                chkfwrite(buffer, sizeof(float), veclen, outfiles[ii]);        } else {            for (ii = 0; ii < numtowrite / veclen; ii++) {                for (jj = 0; jj < numfiles; jj++)                    chkfwrite(buffer, sizeof(float), veclen, outfiles[jj]);            }            for (jj = 0; jj < numfiles; jj++)                chkfwrite(buffer, sizeof(float), numtowrite % veclen, outfiles[jj]);        }        vect_free(buffer);    }}
开发者ID:MilesCranmer,项目名称:presto,代码行数:30,


示例7: prune_powers

int prune_powers(float *arr, int n, int numsumpows)/* Sets powers that are more than approx PRUNELEV standard *//* devs above the median value to NEWLEV times the median  *//* value.  This helps 'clean' the spectrum of high power   *//* signals that probably have nothing to do with a phase   *//* modulation spectrum (i.e. they are RF noise or strong   *//* solitary pulsars.                                       */{    int ii, ct = 0;    float med, cutoff, *tmparr;    /* Determine the median power */    tmparr = gen_fvect(n);    memcpy(tmparr, arr, sizeof(float) * n);    med = median(tmparr, n);    vect_free(tmparr);    /* Throw away powers that are bigger that PRUNELEV * median */    cutoff = med * PRUNELEV / sqrt((float) numsumpows);    for (ii = 0; ii < n; ii++) {        if (arr[ii] > cutoff) {            arr[ii] = NEWLEV * med;            ct++;        }    }    return ct;}
开发者ID:MilesCranmer,项目名称:presto,代码行数:29,


示例8: cst_list

struct vector *cst_vect_from_list(GHashTable *ht, const char *key){    GList *l = cst_list(ht, key);    if (l == NULL)        return NULL;    struct vector * v = vect_new(g_list_length(l), CST_VECT_DIM);    GList *it;    int i = 0, j = 0;    for (it = l; it != NULL; it = it->next) {        GList *l2 = yw_extract_list((osux_yaml*) it->data);        if (l2 == NULL) {            vect_free(v);            return NULL;        }        g_assert(g_list_length(l2) == CST_VECT_DIM);        GList *it2;        for (it2 = l2; it2 != NULL; it2 = it2->next) {            v->t[i][j] = atof(yw_extract_scalar((osux_yaml*) it2->data));            j++;        }        i++;    }    return v;}
开发者ID:tomtix,项目名称:osux,代码行数:26,


示例9: calc_avgmedstd

void calc_avgmedstd(float *arr, int numarr, float fraction,                    int step, float *avg, float *med, float *std)/* Calculates the median and middle-'fraction' std deviation  *//* and average of the array 'arr'.  Values are returned in    *//* 'avg', 'med' and 'std'.  The array is not modified.        */{   int ii, jj, len, start;   float *tmparr;   double davg, dstd;   len = (int) (numarr * fraction + 0.5);   if (len > numarr || len < 0) {      printf("fraction (%g) out-of-bounds in calc_avgmedstd()/n", fraction);      exit(1);   }   start = (numarr - len) / 2;   tmparr = gen_fvect(numarr);   for (ii = 0, jj = 0; ii < numarr; ii++, jj += step)      tmparr[ii] = arr[jj];   qsort(tmparr, numarr, sizeof(float), compare_floats);   avg_var(tmparr + start, len, &davg, &dstd);   *avg = (float) davg;   *med = tmparr[numarr / 2];   *std = sqrt(dstd);   vect_free(tmparr);}
开发者ID:dlakaplan,项目名称:presto,代码行数:26,


示例10: free_mask

void free_mask(mask obsmask)/* Free the contents of an mask structure */{   int ii;   for (ii = 0; ii < obsmask.numint; ii++) {      if (obsmask.num_chans_per_int[ii] > 0 &&          obsmask.num_chans_per_int[ii] <= obsmask.numchan)         vect_free(obsmask.chans[ii]);   }   free(obsmask.chans);   vect_free(obsmask.num_chans_per_int);   if (obsmask.num_zap_chans)      vect_free(obsmask.zap_chans);   if (obsmask.num_zap_ints)      vect_free(obsmask.zap_ints);}
开发者ID:dlakaplan,项目名称:presto,代码行数:17,


示例11: get_decimalstr

/* * get the addtion result with the <decimal base> form  * but if the base is too large (>16) and hard to find  letters to present the digits(maybe >16), then use the <digit1*base1^power1+digit2*base2^power2.....> form */char* get_decimalstr(const vector digits,const ln base){	int i;	char *s1,*s2;	ln digit;	vector decimal;	//produce the decimal string	decimal=vect_create_str("");	if(!decimal)		return NULL;	s2=ln2str(base);	for(i=0;i<vect_getlength(digits);i++)	{		digit=*((ln *)vect_getelmat(digits,i));		if(ln_cmp_int(base,16)>0)		{			if(ln_cmp_int(digit,0)>0)			{				s1=ln2str(digit);				if(i>0)					vect_strcat(decimal,"+");				vect_strcat(decimal,"%s*%s^(%d)",s1,s2,vect_getlength(digits)-i-2);				free(s1);			}		}		else		{			s1=ln2str(digit);			if(i==vect_getlength(digits)-1) //add the point			{				if(strcmp(s1,"0")==0)				{					free(s1);					break;				}				if(vect_getlength(decimal)==0)					vect_strcat(decimal,"0");				vect_strcat(decimal,".");			}			if(strlen(s1)==1) //0-9				vect_strcat(decimal,"%s",s1);			else				vect_strcat(decimal,"%c",'a'+s1[1]-'0'); //10-15 converted to a-f			free(s1);		}	}		//append the base	if(ln_cmp_int(base,16)<=0)		vect_strcat(decimal," %s",s2);	free(s2);	s1=vect2str(decimal);	vect_free(decimal);	return s1;}
开发者ID:198767,项目名称:cyy3,代码行数:61,


示例12: free_datapart

static void free_datapart(datapart * dp){#ifdef USEMMAP   munmap(dp->data, sizeof(float) * dp->nn);#else   vect_free(dp->data);#endif   free(dp);}
开发者ID:SixByNine,项目名称:presto,代码行数:9,


示例13: bary2topo

int bary2topo(double *topotimes, double *barytimes, int numtimes,              double fb, double fbd, double fbdd,              double *ft, double *ftd, double *ftdd)/* Convert a set of barycentric pulsar spin parameters (fb, fbd, fbdd) *//* into topocentric spin parameters (ft, ftd, ftdd) by performing      *//* a linear least-squares fit (using LAPACK routine DGELS).  The       *//* routine equates the pulse phase using topcentric parameters and     *//* times to the pulse phase using barycentric parameters and times.    */{   double *work, *aa, *bb, dtmp;   int ii, mm = 3, nn, nrhs = 1, lwork, info, index;   char trans = 'T';   if (numtimes < 4) {      printf("/n'numtimes' < 4 in bary2topo():  Cannot solve./n/n");      exit(0);   }   nn = numtimes;   lwork = mm + nn * 9;   aa = gen_dvect(mm * nn);   bb = gen_dvect(nn);   work = gen_dvect(lwork);   for (ii = 0; ii < nn; ii++) {      index = ii * 3;      dtmp = (topotimes[ii] - topotimes[0]) * SECPERDAY;      aa[index] = dtmp;      aa[index + 1] = 0.5 * dtmp * dtmp;      aa[index + 2] = dtmp * dtmp * dtmp / 6.0;      dtmp = (barytimes[ii] - barytimes[0]) * SECPERDAY;      bb[ii] = dtmp * (fb + dtmp * (0.5 * fbd + fbdd * dtmp / 6.0));   }   // dgels_(&trans, &mm, &nn, &nrhs, aa, &mm, bb, &nn, work, &lwork, &info);   call_dgels(&trans, mm, nn, nrhs, aa, mm, bb, nn, work, lwork, &info);   *ft = bb[0];   *ftd = bb[1];   *ftdd = bb[2];   vect_free(aa);   vect_free(bb);   vect_free(work);   return info;}
开发者ID:bretonr,项目名称:presto,代码行数:41,


示例14: test_resize

static char * test_resize() {	vect_int *vi = vect_init_int(1);	for (int i=0; i<257; i++) {		vect_push_int(vi, i);	}			mu_assert("error resize: vi->capacity != 512", vi->capacity == 512);	vect_free(vi);	return 0;}
开发者ID:sixthgear,项目名称:collect,代码行数:12,


示例15: free_digit

void free_digit(vector digits){	int i;	ln p;	for(i=0;i<vect_getlength(digits);i++)	{		p=*((ln *)vect_getelmat(digits,i));		ln_free(*p);	}	vect_free(digits);	return;}
开发者ID:198767,项目名称:cyy3,代码行数:12,


示例16: plot_profile

void plot_profile(int proflen, float *profile, const char *title,                  const char *probtxt, const char *foldtxt,                  int showerr, float *errors, int showid){    int ii;    float *x, overy, ymin, ymax;    float errmin = 0.0, errmax = 0.0, offset, avg = 0.0, av[2];    find_min_max_arr(proflen, profile, &ymin, &ymax);    if (showerr)        find_min_max_arr(proflen, errors, &errmin, &errmax);    overy = 0.1 * (ymax + errmax - ymin - errmin);    ymax = ymax + overy + errmax;    ymin = ymin - overy - errmin;    x = gen_fvect(proflen);    for (ii = 0; ii < proflen; ii++)        x[ii] = (float) ii / (float) proflen;    cpgenv(0.0, 1.00001, ymin, ymax, 0, 0);    cpgscf(2);    cpglab("Pulse Phase", "Counts", "");    if (showid)        cpgiden();    cpgslw(5);    if (showerr) {        cpgbin(proflen, x, profile, 0);    } else {        cpgline(proflen, x, profile);    }    cpgslw(1);    if (showerr) {        offset = 0.5 / (float) proflen;        for (ii = 0; ii < proflen; ii++)            x[ii] += offset;        cpgerrb(6, proflen, x, profile, errors, 2);        cpgpt(proflen, x, profile, 5);    }    for (ii = 0; ii < proflen; ii++)        avg += profile[ii];    avg /= proflen;    cpgsls(4);    x[0] = 0.0;    x[1] = 1.0;    av[0] = avg;    av[1] = avg;    cpgline(2, x, av);    cpgsls(1);    cpgsch(1.3);    cpgmtxt("T", +2.0, 0.5, 0.5, title);    cpgsch(1.0);    cpgmtxt("T", +0.8, 0.5, 0.5, foldtxt);    cpgmtxt("T", -1.5, 0.5, 0.5, probtxt);    vect_free(x);}
开发者ID:MilesCranmer,项目名称:presto,代码行数:53,


示例17: plot_rfi

static void plot_rfi(rfi * plotrfi, float top, int numint, int numchan,                     float T, float lof, float hif){   int ii;   float period, perioderr, dy = 0.035, *temparr;   float tr[6] = { -0.5, 1.0, 0.0, -0.5, 0.0, 1.0 };   char temp[40];   if (plotrfi->freq_avg == 0.0)      period = 0.0;   else      period = 1000.0 / plotrfi->freq_avg;   if (plotrfi->freq_var == 0.0)        /* Why are these zero? */      perioderr = 0.0;   else      perioderr = 1000.0 * sqrt(plotrfi->freq_var) /          (plotrfi->freq_avg * plotrfi->freq_avg);   cpgsvp(0.0, 1.0, 0.0, 1.0);   cpgswin(0.0, 1.0, 0.0, 1.0);   cpgnice_output_2(temp, plotrfi->freq_avg, sqrt(plotrfi->freq_var), 0);   cpgptxt(0.03, top - 0.6 * dy, 0.0, 0.0, temp);   cpgnice_output_2(temp, period, perioderr, 0);   cpgptxt(0.12, top - 0.6 * dy, 0.0, 0.0, temp);   sprintf(temp, "%-5.2f", plotrfi->sigma_avg);   cpgptxt(0.21, top - 0.6 * dy, 0.0, 0.0, temp);   sprintf(temp, "%d", plotrfi->numobs);   cpgptxt(0.27, top - 0.6 * dy, 0.0, 0.0, temp);   ii = (numint > numchan) ? numint : numchan;   temparr = gen_fvect(ii);   for (ii = 0; ii < numchan; ii++)      temparr[ii] = GET_BIT(plotrfi->chans, ii);   cpgsvp(0.33, 0.64, top - dy, top);   cpgswin(0.0, numchan, 0.0, 1.0);   cpgimag(temparr, numchan, 1, 1, numchan, 1, 1, 0.0, 1.0, tr);   cpgswin(0.0, numchan, 0.0, 1.0);   cpgbox("BST", 0.0, 0, "BC", 0.0, 0);   cpgswin(lof, hif, 0.0, 1.0);   cpgbox("CST", 0.0, 0, "", 0.0, 0);   for (ii = 0; ii < numint; ii++)      temparr[ii] = GET_BIT(plotrfi->times, ii);   cpgsvp(0.65, 0.96, top - dy, top);   cpgswin(0.0, numint, 0.0, 1.0);   cpgimag(temparr, numint, 1, 1, numint, 1, 1, 0.0, 1.0, tr);   cpgswin(0.0, numint, 0.0, 1.0);   cpgbox("BST", 0.0, 0, "BC", 0.0, 0);   cpgswin(0.0, T, 0.0, 1.0);   cpgbox("CST", 0.0, 0, "", 0.0, 0);   vect_free(temparr);}
开发者ID:ChrisLaidler,项目名称:presto,代码行数:49,


示例18: test_pushpop

static char *test_pushpop() {	int result = 0;	vect_int *vi = vect_init_int(1);	for (int i=0; i<100; i++) 		vect_push_int(vi, i);		while(vi->size)		result += vect_pop_int(vi);			mu_assert("error pushpop: result != 4950", result == 4950);	mu_assert("error pushpop: vi->size != 0", vi->size == 0);	vect_free(vi);	return 0;}
开发者ID:sixthgear,项目名称:collect,代码行数:15,


示例19: correct_subbands_for_DM

void correct_subbands_for_DM(double dm, prepfoldinfo * search,                             double *ddprofs, foldstats * ddstats)/* Calculate the DM delays and apply them to the subbands *//* to create de-dispersed profiles.                      */{   int ii, *dmdelays;   double *subbanddelays, hif, dopplerhif, hifdelay, rdphase;   rdphase = search->fold.p1 * search->proflen;   hif = search->lofreq + (search->numchan - 1.0) * search->chan_wid;   dopplerhif = doppler(hif, search->avgvoverc);   hifdelay = delay_from_dm(dm, dopplerhif);   subbanddelays = subband_delays(search->numchan, search->nsub, dm,                                  search->lofreq, search->chan_wid,                                  search->avgvoverc);   dmdelays = gen_ivect(search->nsub);   for (ii = 0; ii < search->nsub; ii++)      dmdelays[ii] =          NEAREST_INT((subbanddelays[ii] - hifdelay) * rdphase) % search->proflen;   vect_free(subbanddelays);   combine_subbands(search->rawfolds, search->stats, search->npart,                    search->nsub, search->proflen, dmdelays, ddprofs, ddstats);   vect_free(dmdelays);}
开发者ID:bretonr,项目名称:presto,代码行数:24,


示例20: drotate_1d

void drotate_1d(double *data, long numbins, long bins_to_left)/* Rotates a vector by bins_to_left places to the left.    *//* numbins is the number of DOUBLE points to move.         *//* drotate is better.  Use it.                       */{   double *tmp;   if (bins_to_left < 0 || bins_to_left >= numbins) {      printf("/nNumber of bins to rotate array in rotate_1d is/n");      printf("/nout of bounds.  Tried to rotate %ld bins.  Exiting./n",             bins_to_left);      exit(1);   }   tmp = gen_dvect(bins_to_left);   memcpy(tmp, data, sizeof(double) * bins_to_left);   memmove(data, data + bins_to_left, sizeof(double) * (numbins - bins_to_left));   memcpy(data + bins_to_left, tmp, sizeof(double) * bins_to_left);   vect_free(tmp);}
开发者ID:nextgen-astrodata,项目名称:presto,代码行数:19,


示例21: drotate

void drotate(double *data, long numbins, double bins_to_left)/* Rotates a vector by bins_to_left places to the left.    *//* numbins is the number of DOUBLE points to move.         */{   double *tmp, lopart, hipart, intpart;   long i, index;   bins_to_left = fmod(bins_to_left, (double) numbins);   if (bins_to_left < 0.0)      bins_to_left += numbins;   tmp = gen_dvect(numbins);   lopart = modf(bins_to_left, &intpart);   hipart = 1.0 - lopart;   index = (long) floor(intpart + 1.0E-20);   for (i = 0; i < numbins; i++)      tmp[i] = hipart * data[(index + i) % numbins] +          lopart * data[(index + i + 1) % numbins];   memcpy(data, tmp, sizeof(double) * numbins);   vect_free(tmp);}
开发者ID:nextgen-astrodata,项目名称:presto,代码行数:20,


示例22: max_rz_file_harmonics

void max_rz_file_harmonics(FILE * fftfile, int num_harmonics,                             int lobin,                             double rin, double zin,                             double *rout, double *zout, rderivs derivs[],                             double maxpow[])/* Return the Fourier frequency and Fourier f-dot that      *//* maximizes the power of the candidate in 'fftfile'.       *//* WARNING: not tested */{   int i;   double maxz, rin_int, rin_frac;   int kern_half_width, filedatalen, extra = 10;   int* r_offset;   fcomplex** filedata;   r_offset = (int*)malloc(sizeof(int)*num_harmonics);   filedata = (fcomplex**)malloc(sizeof(fcomplex*)*num_harmonics);   maxz = fabs(zin*num_harmonics) + 4.0;   kern_half_width = z_resp_halfwidth(maxz, HIGHACC);   filedatalen = 2 * kern_half_width + extra;   for (i=1;i<=num_harmonics;i++) {       rin_frac = modf(rin*i, &rin_int);       r_offset[i-1] = (int) rin_int - filedatalen / 2 + lobin;       filedata[i-1] = read_fcomplex_file(fftfile, r_offset[i-1], filedatalen);   }   rin_frac = modf(rin, &rin_int);   max_rz_arr_harmonics(filedata, num_harmonics,                        r_offset,                        filedatalen, rin_frac + filedatalen / 2,                        zin, rout, zout, derivs,                        maxpow);   *rout += r_offset[0];   for (i=1;i<=num_harmonics;i++) {       vect_free(filedata[i-1]);   }   free(r_offset);   free(filedata);}
开发者ID:ChrisLaidler,项目名称:presto,代码行数:40,


示例23: test_fibs_build

static char * test_fibs_build() {	/* build fibs sequence */	uint64_t result;	vect_ui64 *vl = vect_init_ui64(8);	uint64_t a = 0;	uint64_t b = 1;		vect_push_ui64(vl, 0);	for(int i=1; i<94; i++) {		uint64_t tmp = a;		a = a + b;		b = tmp;		vect_push_ui64(vl, a);	}			result = vect_at_ui64(vl, vl->size-1);		mu_assert("error fibs: result != 12200160415121876738", 			       result == 12200160415121876738ULL);	vect_free(vl);	return 0;}
开发者ID:sixthgear,项目名称:collect,代码行数:22,


示例24: subband_delays

double *subband_search_delays(int numchan, int numsubbands, double dm,                              double lofreq, double chanwidth, double voverc)/* Return an array of delays (sec) for a subband DM search.  The      *//* delays are calculated normally for each of the 'numchan' channels  *//* using the appropriate frequencies at the 'dm'.  Then the delay     *//* from the highest frequency channel of each of the 'numsubbands'    *//* subbands is subtracted from each subband.  This gives the subbands *//* the correct delays for each freq in the subband, but the subbands  *//* themselves are offset as if they had not been de-dispersed.  This  *//* way, we can call float_dedisp() on the subbands if needed.         *//* 'lofreq' is the center frequency in MHz of the lowest frequency    *//* channel.  'chanwidth' is the width in MHz of each channel.  The    *//* returned array is allocated by this routine.  'voverc' is used to  *//* correct the input frequencies for doppler effects.  See the        *//* comments in dedisp_delays() for more info.                         *//* Note:  When performing a subband search, the delays for each       *//*   subband must be calculated with the frequency of the highest     *//*   channel in each subband, _not_ the center subband frequency.     */{    int ii, jj, chan_per_subband;    double *delays, *subbanddelays;    chan_per_subband = numchan / numsubbands;    /* Calculate the appropriate delays to subtract from each subband */    subbanddelays = subband_delays(numchan, numsubbands, dm,                                   lofreq, chanwidth, voverc);    /* Calculate the appropriate delays for each channel */    delays = dedisp_delays(numchan, dm, lofreq, chanwidth, voverc);    for (ii = 0; ii < numsubbands; ii++)        for (jj = 0; jj < chan_per_subband; jj++)            delays[ii * chan_per_subband + jj] -= subbanddelays[ii];    vect_free(subbanddelays);    return delays;}
开发者ID:caseyjlaw,项目名称:presto,代码行数:39,


示例25: max_rz_file

double max_rz_file(FILE * fftfile, double rin, double zin,                   double *rout, double *zout, rderivs * derivs)/* Return the Fourier frequency and Fourier f-dot that      *//* maximizes the power of the candidate in 'fftfile'.       */{   double maxz, maxpow, rin_int, rin_frac;   int kern_half_width, filedatalen, startbin, extra = 10;   fcomplex *filedata;   maxz = fabs(zin) + 4.0;   rin_frac = modf(rin, &rin_int);   kern_half_width = z_resp_halfwidth(maxz, HIGHACC);   filedatalen = 2 * kern_half_width + extra;   startbin = (int) rin_int - filedatalen / 2;   filedata = read_fcomplex_file(fftfile, startbin, filedatalen);   maxpow = max_rz_arr(filedata, filedatalen, rin_frac + filedatalen / 2,                       zin, rout, zout, derivs);   *rout += startbin;   vect_free(filedata);   return maxpow;}
开发者ID:ChrisLaidler,项目名称:presto,代码行数:22,


示例26: malloc

static basicstats *calc_stats(dataview * dv, datapart * dp){   int ii, jj;   float *tmpdata;   basicstats *tmpstats;   tmpstats = (basicstats *) malloc(sizeof(basicstats));   tmpstats->max = SMALLNUM;   tmpstats->min = LARGENUM;   tmpdata = gen_fvect(dv->numsamps);   for (ii = 0, jj = dv->lon - dp->nlo; ii < dv->numsamps; ii++, jj++) {      tmpdata[ii] = dp->data[jj];      if (tmpdata[ii] > tmpstats->max)         tmpstats->max = tmpdata[ii];      if (tmpdata[ii] < tmpstats->min)         tmpstats->min = tmpdata[ii];   }   stats(tmpdata, dv->numsamps, &tmpstats->average, &tmpstats->stdev,         &tmpstats->skewness, &tmpstats->kurtosis);   tmpstats->stdev = sqrt(tmpstats->stdev);   tmpstats->median = median(tmpdata, dv->numsamps);   vect_free(tmpdata);   return tmpstats;}
开发者ID:SixByNine,项目名称:presto,代码行数:24,


示例27: corr_rz_plane

fcomplex *corr_rz_interp(fcomplex * data, int numdata, int numbetween,                         int startbin, double z, int fftlen,                         presto_interp_acc accuracy, int *nextbin)  /* This routine uses the correlation method to do a Fourier        */  /* complex interpolation of a slice of the f-fdot plane.           */  /* Arguments:                                                      */  /*   'data' is a complex array of the data to be interpolated.     */  /*   'numdata' is the number of complex points (bins) in data.     */  /*   'numbetween' is the number of points to interpolate per bin.  */  /*   'startbin' is the first bin to use in data for interpolation. */  /*   'z' is the fdot to use (z=f-dot*T^2).                         */  /*   'fftlen' is the # of complex pts in kernel and result.        */  /*   'accuracy' is either HIGHACC or LOWACC.                       */  /*   'nextbin' will contain the bin number of the first bin not    */  /*      interpolated in data.                                      */{   fcomplex **result, *tempreturn;   result = corr_rz_plane(data, numdata, numbetween, startbin, z, z, 1,                          fftlen, accuracy, nextbin);   tempreturn = result[0];   vect_free(result);   return tempreturn;}
开发者ID:SixByNine,项目名称:presto,代码行数:24,


示例28: twopassfft_scratch

//.........这里部分代码省略.........      dp = data;      fp = sizeof(rawtype) * ii;      df = sizeof(rawtype) * n2;      for (jj = 0; jj < n1; jj++) {         fseek_multifile(infile, fp, SEEK_SET);         fread_multifile(dp, sizeof(rawtype), bb, infile);         dp += bb;              /* Data ptr */         fp += df;              /* File ptr */      }      /* Transpose the n1 (rows) x bb (cols) block of data */      transpose_fcomplex(data, n1, bb, move, move_size);      /* Do bb transforms of length n1 */      for (jj = 0; jj < bb; jj++)         COMPLEXFFT(data + jj * n1, n1, isign);      /* Multiply the matrix A(ii,jj) by exp(isign 2 pi i jj ii / nn). */      /* Use recursion formulas from Numerical Recipes.                */      for (jj = 0; jj < bb; jj++) {         delta = isign * TWOPI * (ii + jj) / nn;         wr = cos(delta);         wi = sin(delta);         wtemp = sin(0.5 * delta);         wpr = -2.0 * wtemp * wtemp;         wpi = wi;         kind = jj * n1 + 1;         for (kk = 1; kk < n1; kk++, kind++) {            tmp1 = data[kind].r;            tmp2 = data[kind].i;            data[kind].r = tmp1 * wr - tmp2 * wi;            data[kind].i = tmp2 * wr + tmp1 * wi;            wtemp = wr;            wr = wtemp * wpr - wi * wpi + wr;            wi = wi * wpr + wtemp * wpi + wi;         }      }      fwrite_multifile(data, sizeof(rawtype), bb * n1, scratch);   }   /* Now do n1 transforms of length n2 by fetching  */   /* groups of size n2 (rows) x bb (cols) blocks.   */   for (ii = 0; ii < n1; ii += bb) {      /* Read two n2 (rows) x bb (cols) blocks from the file */      dp = data;      fp = sizeof(rawtype) * ii;      df = sizeof(rawtype) * n1;      for (jj = 0; jj < n2; jj++) {         fseek_multifile(scratch, fp, SEEK_SET);         fread_multifile(dp, sizeof(rawtype), bb, scratch);         dp += bb;              /* Data ptr */         fp += df;              /* File ptr */      }      /* Transpose the n2 (rows) x bb (cols) block of data */      transpose_fcomplex(data, n2, bb, move, move_size);      /* Do bb transforms of length n2 */      for (jj = 0; jj < bb; jj++)         COMPLEXFFT(data + jj * n2, n2, isign);      /* Transpose the bb (rows) x n2 (cols) block of data */      transpose_fcomplex(data, bb, n2, move, move_size);      /* Scale the data if needed */      if (isign == 1) {         tmp1 = 1.0 / (double) nn;         for (jj = 0; jj < n2 * bb; jj++) {            data[jj].r *= tmp1;            data[jj].i *= tmp1;         }      }      /* Write n2 (rows) x bb (cols) blocks to the file  */      dp = data;      fp = sizeof(rawtype) * ii;      df = sizeof(rawtype) * n1;      for (jj = 0; jj < n2; jj++) {         fseek_multifile(infile, fp, SEEK_SET);         fwrite_multifile(dp, sizeof(rawtype), bb, infile);         dp += bb;              /* Data ptr */         fp += df;              /* File ptr */      }   }   free(move);   vect_free(data);}
开发者ID:ChrisLaidler,项目名称:presto,代码行数:101,


示例29: main

//.........这里部分代码省略.........      chkfread(bytemask[0], numint * numchan, 1, bytemaskfile);      fclose(bytemaskfile);      for (ii = 0; ii < numint; ii++)         for (jj = 0; jj < numchan; jj++)            bytemask[ii][jj] &= PADDING;        /* Clear all but the PADDING bits */      inttime = ptsperint * idata.dt;   }   /* Make the plots and set the mask */   {      int *zapints, *zapchan;      int numzapints = 0, numzapchan = 0;      if (cmd->zapintsstrP) {         zapints = ranges_to_ivect(cmd->zapintsstr, 0, numint - 1, &numzapints);         zapints = (int *) realloc(zapints, (size_t) (sizeof(int) * numint));      } else {         zapints = gen_ivect(numint);      }      if (cmd->zapchanstrP) {         zapchan = ranges_to_ivect(cmd->zapchanstr, 0, numchan - 1, &numzapchan);         zapchan = (int *) realloc(zapchan, (size_t) (sizeof(int) * numchan));      } else {         zapchan = gen_ivect(numchan);      }      rfifind_plot(numchan, numint, ptsperint, cmd->timesigma, cmd->freqsigma,                   cmd->inttrigfrac, cmd->chantrigfrac,                   dataavg, datastd, datapow, zapchan, numzapchan,                   zapints, numzapints, &idata, bytemask,                   &oldmask, &newmask, rfivect, numrfi,                   cmd->rfixwinP, cmd->rfipsP, cmd->xwinP);      vect_free(zapints);      vect_free(zapchan);   }   /* Write the new mask and bytemask to the file */   write_mask(maskfilenm, &newmask);   bytemaskfile = chkfopen(bytemaskfilenm, "wb");   chkfwrite(bytemask[0], numint * numchan, 1, bytemaskfile);   fclose(bytemaskfile);   /* Determine the percent of good and bad data */   {      int numpad = 0, numbad = 0, numgood = 0;      for (ii = 0; ii < numint; ii++) {         for (jj = 0; jj < numchan; jj++) {            if (bytemask[ii][jj] == GOODDATA) {               numgood++;            } else {               if (bytemask[ii][jj] & PADDING)                  numpad++;               else                  numbad++;            }         }      }      printf("/nTotal number of intervals in the data:  %d/n/n", numint * numchan);      printf("  Number of padded intervals:  %7d  (%6.3f%%)/n",             numpad, (float) numpad / (float) (numint * numchan) * 100.0);      printf("  Number of  good  intervals:  %7d  (%6.3f%%)/n",             numgood, (float) numgood / (float) (numint * numchan) * 100.0);
开发者ID:nextgen-astrodata,项目名称:presto,代码行数:67,



注:本文中的vect_free函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ vector2d函数代码示例
C++ vecadd函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。