//------------------------------------- // compute number of element by cluster //------------------------------------- void XEMModel::computeNk() { int64_t k; int64_t i; double ** p_tabCik = _tabCik ; // parcours le tableau _tabCik double * w = _data->_weight;// parcours des poids double wi; // poids courant double * p_tabCik_i; // initialisation initToZero(_tabNk,_nbCluster); for(i=0 ; i<_nbSample ; i++) { wi = *w; p_tabCik_i = *p_tabCik; for(k=0 ; k<_nbCluster ; k++) { _tabNk[k] += p_tabCik_i[k] * wi; } p_tabCik++; w++; } // verification for(k=0 ; k<_nbCluster ; k++) { if (_tabNk[k]==0.0) { throw nullNk; } } }
void XEMGaussianParameter::computeMeanOne(double * Mean, double * weight, double** y_Store, int64_t nbSample, double totalWeight)const{ double ** p_yStore = y_Store; double * p_weight = weight; double * p_yStore_i; int64_t p; int64_t i; double wi; initToZero(Mean,_pbDimension); for(i=0 ; i<nbSample ; i++){ p_yStore_i = *p_yStore; wi = *p_weight; for(p=0 ; p<_pbDimension ; p++){ Mean[p] += p_yStore_i[p] * wi; } p_weight++; p_yStore++; } for(p=0 ; p<_pbDimension ; p++){ Mean[p] /= totalWeight; } }
void QSnpgwa::process(){ int sz = data->geno_size(); // This is the primary loop. for(int i=0;i < sz;i++){ SnpInfo s; ContPopStatsResults p; ContGenoStatsResults g; s.index = i+param_reader->get_begin(); data->get_map_info(i, s.chr, s.name, s.position); data->get_allele_codes(i, s.majAllele, s.minAllele, s.refAllele); if(s.majAllele == ' '){ s.majAllele = '.'; } if(s.minAllele == ' '){ s.minAllele = '.'; } if(s.refAllele == ' '){ s.refAllele = '.'; } // calc difference in genetic position. if(i < sz-1){ string t, chr; int pos = 0; data->get_map_info(i+1, chr, t, pos); if(chr.compare(s.chr) == 0){ s.diff = pos-s.position; }else{ s.diff = -999; } }else{ s.diff = -999; } if(data->getDataObject()->isUsable(i)){ ContPopStats pop_calc(data); ContGenoStats gen_calc(data); LinkageDisequilibrium ld(data); ld.enslave(snp_param); // We have to do this or the ld engine will think // that it owns the data and might erase it. LinkageMeasures lr; pop_calc.prepPopStatsForOutput(i,p); gen_calc.prepGenoStatsForOutput(i,g); if(i + 1 < data->geno_size()){ ld.dprimeOnPair(i, i+1, lr); g.rsquare = lr.rsquare; g.dprime = lr.dPrime; }else{ g.rsquare = g.dprime = -1.0; } }else{ initToZero(p, g); } out.writeLine(i, s,p,g); } out.close(); }
/////////////////////////////////////////////////////////////////////// // Class : CStochastic // Method : rasterBegin // Description : /// \brief Begin drawing an image // Return Value : - // Comments : void CStochastic::rasterBegin(int w,int h,int l,int t,int nullBucket) { int i,j,pxi,pxj; float zoldStart; CFragment *cFragment; assert(numFragments == 0); zoldStart = CRenderer::clipMax; // Set the digits width = w; height = h; left = l; top = t; sampleWidth = width*CRenderer::pixelXsamples + 2*CRenderer::xSampleOffset; sampleHeight = height*CRenderer::pixelYsamples + 2*CRenderer::ySampleOffset; right = left + sampleWidth; bottom = top + sampleHeight; // Early-out if we have no data if (!(CRenderer::flags & OPTIONS_FLAGS_DEEP_SHADOW_RENDERING) && nullBucket) return; assert(sampleWidth <= totalWidth); assert(sampleHeight <= totalHeight); // Init the occlusion culler to zero initToZero(); for (i=0,pxi=CRenderer::pixelYsamples-CRenderer::ySampleOffset;i<sampleHeight;i++,pxi++) { CPixel *pixel = fb[i]; if (pxi >= CRenderer::pixelYsamples) pxi = 0; for (j=0,pxj=CRenderer::pixelXsamples-CRenderer::xSampleOffset;j<sampleWidth;j++,pxj++,pixel++) { float aperture[2]; // The stratified sample pixel->jx = (CRenderer::jitter*(urand()-0.5f) + 0.5001011f); pixel->jy = (CRenderer::jitter*(urand()-0.5f) + 0.5001017f); // Time of the sample for motion blur if (pxj >= CRenderer::pixelXsamples) pxj = 0; pixel->jt = ( pxi*CRenderer::pixelXsamples + pxj + CRenderer::jitter*(urand()-0.5f) + 0.5001011f)/(float)(CRenderer::pixelXsamples*CRenderer::pixelYsamples); // Importance blend / jitter pixel->jimp = 1.0f - ( pxj*CRenderer::pixelYsamples + pxi + CRenderer::jitter*(urand()-0.5f) + 0.5001011f)/(float)(CRenderer::pixelXsamples*CRenderer::pixelYsamples); if (CRenderer::flags & OPTIONS_FLAGS_FOCALBLUR) { // Aperture sample for depth of field while (TRUE) { apertureGenerator.get(aperture); aperture[0] = 2.0f*aperture[0] - 1.0f; aperture[1] = 2.0f*aperture[1] - 1.0f; if ((aperture[0]*aperture[0] + aperture[1]*aperture[1]) < 1.0f) break; } pixel->jdx = aperture[0]; pixel->jdy = aperture[1]; } else { pixel->jdx = 0; pixel->jdy = 0; } // Center location of the sample pixel->xcent = (j+pixel->jx) + left; pixel->ycent = (i+pixel->jy) + top; pixel->z = CRenderer::clipMax; pixel->zold = zoldStart; pixel->numSplats = 0; pixel->node = getNode(j,i); pixel->node->zmax = CRenderer::clipMax; cFragment = &pixel->last; cFragment->z = CRenderer::clipMax; initv(cFragment->color,0); initv(cFragment->opacity,0); cFragment->next = NULL; cFragment->prev = &pixel->first; // The last sample's extra samples are genuine AOV data if (CRenderer::numExtraSamples > 0) memcpy(cFragment->extraSamples,CRenderer::sampleDefaults,sizeof(float)*CRenderer::numExtraSamples); initv(cFragment->accumulatedOpacity,0); cFragment = &pixel->first; cFragment->z = -C_INFINITY; initv(cFragment->color,0); initv(cFragment->opacity,0); cFragment->next = &pixel->last; cFragment->prev = NULL; // Note: The first fragment's extra samples are not used, and the pointer is NULL assert(cFragment->extraSamples == NULL); initv(cFragment->accumulatedOpacity,0); pixel->update = &pixel->first; } } resetHierarchy(); }