Ejemplo n.º 1
0
/* Updating of coefficients */
void updatecoeff(double *hr,double *hi, int Ntap,
                 double *xr,double *xi, int Ndim,
                 double outr, double outi, double mu, double R)
{
    double k = mu * errorfun(outr,outi,R);
    int i;
    for(i=0;i<Ntap;i++)
    {
        *(hr+i) += k * (outr * xr[i] + outi * xi[i]);
        *(hi+i) += k * (outi * xr[i] - outr * xi[i]);
        *(hr+i+Ntap) += k * (outr * xr[i+Ndim] + outi * xi[i+Ndim]);
        *(hi+i+Ntap) += k * (outi * xr[i+Ndim] - outr * xi[i+Ndim]); 
    }
}
Ejemplo n.º 2
0
void mask_mainsub_check(CATALOGUE *CatB,SUBCATALOGUE *SubCatB,HBTInt proSubID,HBTInt desID,HBTInt son)
{/* CatB.HaloMask must have been initialized with all ones before calling
	* SubCatB's nonmain subs must have been filled before doing the mask
	* */
	HBTInt i,j,k,pid,subid,desSubID;
	HBTInt *GrpPIDs,*MainPIDs;
	short *catmask;
	catmask=calloc(NP_DM,sizeof(short));
	desSubID=SubCatB->GrpOffset_Sub[desID];
	GrpPIDs=CatB->PIDorIndex+CatB->Offset[desID];
	for(i=0;i<CatB->Len[desID];i++)
	{
		if(CatB->HaloMask[GrpPIDs[i]]==0)
			errorfun(0,desID,i,GrpPIDs[i]);
		catmask[GrpPIDs[i]]=1;
	}
	j=0;
	for(i=1;i<SubCatB->GrpLen_Sub[desID];i++)
	{
		subid=desSubID+i;
		j+=SubCatB->SubLen[subid];
		for(pid=0;pid<SubCatB->SubLen[subid];pid++)
		{
			if(CatB->HaloMask[SubCatB->PSubArr[subid][pid]]==0)
			errorfun(1,subid,i,SubCatB->PSubArr[subid][pid]);
			else 
			CatB->HaloMask[SubCatB->PSubArr[subid][pid]]=0;
			if(catmask[SubCatB->PSubArr[subid][pid]]==0)//outlier
			printf("subid"HBTIFMT",i"HBTIFMT",ind"HBTIFMT",pid"HBTIFMT"\n",subid,i,pid,SubCatB->PSubArr[subid][pid]);
		}
	}
	SubCatB->SubLen[desSubID]=CatB->Len[desID]-j;
	MainPIDs=mymalloc(sizeof(HBTInt)*SubCatB->SubLen[desSubID]);
	
	if(j==0)//single pro or infantry Grp,need no mask
		memcpy(MainPIDs,GrpPIDs,sizeof(HBTInt)*CatB->Len[desID]);
	else
	{
		j=0;
		for(i=0;i<CatB->Len[desID];i++)
		{
			if(CatB->HaloMask[pid=GrpPIDs[i]])
			{
				MainPIDs[j]=pid;
				j++;
			}
		}
		if(j!=SubCatB->SubLen[desSubID])//what about if there're duplicate particles???
		{
			fprintf(logfile,"error: Mask Fof len mismatch! \n for desID="HBTIFMT"\n,remained="HBTIFMT",expected="HBTIFMT"",desID,j,SubCatB->SubLen[desSubID]);fflush(logfile);
			exit(1);
		}
	}
	SubCatB->PSubArr[desSubID]=MainPIDs;
	SubCatB->SubRank[desSubID]=0;
	SubCatB->HaloChains[desSubID].ProSubID=proSubID;
	SubCatB->HaloChains[desSubID].HostID=desID;
	SubCatB->sub_hierarchy[desSubID].nibs=-1;
	SubCatB->sub_hierarchy[desSubID].pre=-1;
	SubCatB->sub_hierarchy[desSubID].next=-1;
	SubCatB->sub_hierarchy[desSubID].sub=son;
}