void TaxonomyVertex :: SaveNeighbours ( SaveLoadManager& m ) const { const_iterator p, p_end; m.saveUInt(neigh(true).size()); for ( p = begin(true), p_end = end(true); p != p_end; ++p ) m.savePointer(*p); m.saveUInt(neigh(false).size()); for ( p = begin(false), p_end = end(false); p != p_end; ++p ) m.savePointer(*p); m.o() << "\n"; }
bool Skeleton_basic::operator() ( clipper::Xmap<int>& xskl, const clipper::Xmap<float>& xmap ) const { std::vector<int> index; clipper::Xmap<float>::Map_reference_index ix; /* now get the map in sorted order. We only sort those points which are to be considered, i.e. non-zero */ for ( ix = xmap.first(); !ix.last(); ix.next() ) if ( xskl[ix] > 0 ) index.push_back( ix.index() ); Map_index_sort::sort_increasing( xmap, index ); /* make neighbours The neighbours of a point are the other grid points which are 'near' it. The exact choice depends on the grid geometry. The cutoff is chosen to give 18-20 neighbours. For a cubic grid, these are a 3x3x3 cube without the vertices, for a hex grid they are a hexagonal cylinder. */ Skeleton_basic::Neighbours neigh( xmap ); /* make the skeleton map. This will contain: 0 for non-skeleton grids (inter ridge spaces) 1 for untested grids 1 for skeleton grids (ridges) (The untested and skeleton grids can have the same value, because the untested ones are still in the index). We loop through point in order, starting with the lowest and decide whether each one is part of the skeleton. */ for ( int i = 0; i < index.size(); i++ ) if ( !isInSkel( xskl, xskl.coord_of(index[i]), neigh, box_ ) ) xskl.set_data( index[ i ], 0 ); return true; }
void correl(long nmax, float *y, float eps, long m, float *c, long id, long nmin, long ncmin, long ipmin) { long i,nn,np,n,nlast,nfound; static long jh[IM*IM+1],ipairs[MM],jpntr[NX],nlist[NX]; float s; if(nmax>NX || m>MM) {printf("Make NX/MM larger."); exit(1);} for(i=1; i<m; i++) ipairs[i]=0; base(nmax,y,id,2,jh,jpntr,eps); for(n=(m-1)*id; n<nmax; n++){ nfound=neigh(nmax,y,n,n-nmin,id,2,jh,jpntr,eps,nlist); ipairs[1]+=nfound; /* all neighbours in two dimensions */ for(nn=0; nn<nfound; nn++){ np=nlist[nn]; if(np>=(m-1)*id) for(i=2; i<m; i++){ if(fabs((double)(y[n-i*id]-y[np-i*id]))>=eps) break; ipairs[i]++; /* neighbours in $3,\ldots,m$ dimensions */ } } if(n-nmin-(m-1)*id >= ncmin && ipairs[m-1] >= ipmin) break; } s=(float)(n-nmin-(m-1)*id+1)*(float)(n-nmin-(m-1)*id)/2; for(i=1; i<m; i++) c[i+1]=ipairs[i]/s; /* normalisation */ /*!*/ printf("%f %ld %f %ld %ld\n", eps, n-(m-1)*id,s,ipairs[2],ipairs[m-1]); }
void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) { if(m_selecting && (event->button() == Qt::LeftButton || event->button() == Qt::RightButton)) { MapHandlerGen* mh = m_schnapps->getSelectedMap(); const MapParameters& p = h_parameterSet[mh]; if(p.positionAttribute.isValid()) { unsigned int orbit = m_schnapps->getCurrentOrbit(); CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit); if(selector) { PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(mh)->getMap(); switch(orbit) { case VERTEX : { CellSelector<PFP2::MAP, VERTEX>* cs = static_cast<CellSelector<PFP2::MAP, VERTEX>*>(selector); if(m_selectingVertex.valid()) { m_selectedVertices_dirty = true; switch(p.selectionMethod) { case SingleCell : { if(event->button() == Qt::LeftButton) cs->select(m_selectingVertex); else if(event->button() == Qt::RightButton) cs->unselect(m_selectingVertex); break; } case WithinSphere : { Algo::Surface::Selection::Collector_WithinSphere<PFP2> neigh(*map, p.positionAttribute, m_selectionRadiusBase * m_selectionRadiusCoeff); neigh.collectAll(m_selectingVertex); if(event->button() == Qt::LeftButton) cs->select(neigh.getInsideVertices()); else if(event->button() == Qt::RightButton) cs->unselect(neigh.getInsideVertices()); break; } case NormalAngle : { if(p.normalAttribute.isValid()) { Algo::Surface::Selection::Collector_NormalAngle<PFP2> neigh(*map, p.normalAttribute, m_normalAngleThreshold); neigh.collectAll(m_selectingVertex); if(event->button() == Qt::LeftButton) cs->select(neigh.getInsideVertices()); else if(event->button() == Qt::RightButton) cs->unselect(neigh.getInsideVertices()); } break; } } } break; } case EDGE : { CellSelector<PFP2::MAP, EDGE>* cs = static_cast<CellSelector<PFP2::MAP, EDGE>*>(selector); if(m_selectingEdge.valid()) { m_selectedEdges_dirty = true; switch(p.selectionMethod) { case SingleCell : { if(event->button() == Qt::LeftButton) cs->select(m_selectingEdge); else if(event->button() == Qt::RightButton) cs->unselect(m_selectingEdge); break; } case WithinSphere : { Algo::Surface::Selection::Collector_WithinSphere<PFP2> neigh(*map, p.positionAttribute, m_selectionRadiusBase * m_selectionRadiusCoeff); neigh.collectAll(m_selectingEdge); if(event->button() == Qt::LeftButton) cs->select(neigh.getInsideEdges()); else if(event->button() == Qt::RightButton) cs->unselect(neigh.getInsideEdges()); break; } case NormalAngle : { if(p.normalAttribute.isValid()) { Algo::Surface::Selection::Collector_NormalAngle<PFP2> neigh(*map, p.normalAttribute, m_normalAngleThreshold); neigh.collectAll(m_selectingEdge); if(event->button() == Qt::LeftButton) cs->select(neigh.getInsideEdges()); else if(event->button() == Qt::RightButton) cs->unselect(neigh.getInsideEdges()); } break; } } } break; } case FACE : { CellSelector<PFP2::MAP, FACE>* cs = static_cast<CellSelector<PFP2::MAP, FACE>*>(selector); if(m_selectingFace.valid()) { m_selectedFaces_dirty = true; switch(p.selectionMethod) { case SingleCell : { if(event->button() == Qt::LeftButton) cs->select(m_selectingFace); else if(event->button() == Qt::RightButton) cs->unselect(m_selectingFace); break; } case WithinSphere : { Algo::Surface::Selection::Collector_WithinSphere<PFP2> neigh(*map, p.positionAttribute, m_selectionRadiusBase * m_selectionRadiusCoeff); neigh.collectAll(m_selectingFace); if(event->button() == Qt::LeftButton) cs->select(neigh.getInsideFaces()); else if(event->button() == Qt::RightButton) cs->unselect(neigh.getInsideFaces()); break; } case NormalAngle : { if(p.normalAttribute.isValid()) { Algo::Surface::Selection::Collector_NormalAngle<PFP2> neigh(*map, p.normalAttribute, m_normalAngleThreshold); neigh.collectAll(m_selectingFace); if(event->button() == Qt::LeftButton) cs->select(neigh.getInsideFaces()); else if(event->button() == Qt::RightButton) cs->unselect(neigh.getInsideFaces()); } break; } } } break; } } } } } }
int coll(void) { int arg; time_t now; char *p; struct lonstr loan; struct sctstr sect; struct natstr *lonee_np; coord x, y; double owed; double pay; char buf[1024]; if (!opt_LOANS) { pr("Loans are not enabled.\n"); return RET_FAIL; } if ((arg = onearg(player->argp[1], "Collect on loan # ")) < 0) return RET_SYN; /* Check if it's a valid loan. That means, is it a valid loan, owed to this player, with a valid duration and it's been signed. */ if (!getloan(arg, &loan) || (loan.l_loner != player->cnum) || (loan.l_ldur == 0) || (loan.l_status != LS_SIGNED)) { pr("You aren't owed anything on that loan...\n"); return RET_FAIL; } /* If we got here, we check to see if it's been defaulted on. We already know it's owed to this player. */ owed = loan_owed(&loan, time(&now)); if (now <= loan.l_duedate) { pr("There has been no default on loan %d\n", arg); return RET_FAIL; } lonee_np = getnatp(loan.l_lonee); pr("You are owed $%.2f on that loan.\n", owed); p = getstarg(player->argp[2], "What sector do you wish to confiscate? ", buf); if (!p) return RET_SYN; if (!check_loan_ok(&loan)) return RET_FAIL; if (!sarg_xy(p, &x, &y) || !getsect(x, y, §)) return RET_SYN; if (!neigh(x, y, player->cnum)) { pr("You are not adjacent to %s\n", xyas(x, y, player->cnum)); return RET_FAIL; } if (sect.sct_own != loan.l_lonee) { pr("%s is not owned by %s.\n", xyas(x, y, player->cnum), cname(loan.l_lonee)); return RET_FAIL; } pay = appraise_sect(§); if (pay > owed * 1.2) { pr("That sector (and its contents) is valued at more than %.2f.\n", owed); return RET_FAIL; } if (!influx(lonee_np) && sect.sct_x == lonee_np->nat_xcap && sect.sct_y == lonee_np->nat_ycap) { pr("%s's capital cannot be confiscated.\n", cname(loan.l_lonee)); return RET_FAIL; } pr("That sector (and its contents) is valued at $%.2f\n", pay); sect.sct_item[I_MILIT] = 1; /* FIXME now where did this guy come from? */ /* * Used to call takeover() here a long time ago, but that does * unwanted things, like generate che. */ sect.sct_own = player->cnum; memset(sect.sct_dist, 0, sizeof(sect.sct_dist)); memset(sect.sct_del, 0, sizeof(sect.sct_del)); sect.sct_off = 1; sect.sct_dist_x = sect.sct_x; sect.sct_dist_y = sect.sct_y; putsect(§); nreport(player->cnum, N_SEIZE_SECT, loan.l_lonee, 1); owed = loan_owed(&loan, time(&now)); if (pay >= owed) { loan.l_status = LS_FREE; loan.l_ldur = 0; nreport(loan.l_lonee, N_REPAY_LOAN, player->cnum, 1); wu(0, loan.l_lonee, "%s seized %s to satisfy loan #%d\n", cname(player->cnum), xyas(sect.sct_x, sect.sct_y, loan.l_lonee), arg); pr("That loan is now considered repaid.\n"); } else { (void)time(&loan.l_lastpay); owed -= pay; loan.l_amtdue = (int)owed; pay += loan.l_amtpaid; loan.l_amtpaid = (int)pay; wu(0, loan.l_lonee, "%s seized %s in partial payment of loan %d.\n", cname(player->cnum), xyas(sect.sct_x, sect.sct_y, loan.l_lonee), arg); pr("You are still owed $%.2f on loan %d.\n", owed, arg); } putloan(arg, &loan); return RET_OK; }
Graph::Graph(const int *cartan, const std::vector<Word>& gens, //namesake const std::vector<Word>& v_cogens, const std::vector<Word>& e_gens, const std::vector<Word>& f_gens, const Vect& weights) { //define symmetry group relations std::vector<Word> words = words_from_cartan(cartan); { const Logging::fake_ostream& os = logger.debug(); os << "relations ="; for (int w=0; w<6; ++w) { Word& word = words[w]; os << "\n "; for (unsigned i=0; i<word.size(); ++i) { os << word[i]; } } os |0; } //check vertex stabilizer generators { const Logging::fake_ostream& os = logger.debug(); os << "v_cogens ="; for (unsigned w=0; w<v_cogens.size(); ++w) { const Word& jenn = v_cogens[w]; //namesake os << "\n "; for (unsigned t=0; t<jenn.size(); ++t) { int j = jenn[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //check edge generators { const Logging::fake_ostream& os = logger.debug(); os << "e_gens ="; for (unsigned w=0; w<e_gens.size(); ++w) { const Word& edge = e_gens[w]; os << "\n "; for (unsigned t=0; t<edge.size(); ++t) { int j = edge[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //check face generators { const Logging::fake_ostream& os = logger.debug(); os << "f_gens ="; for (unsigned w=0; w<f_gens.size(); ++w) { const Word& face = f_gens[w]; os << "\n "; for (unsigned t=0; t<face.size(); ++t) { int j = face[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //build symmetry group Group group(words); logger.debug() << "group.ord = " << group.ord |0; //build subgroup std::vector<int> subgroup; subgroup.push_back(0); std::set<int> in_subgroup; in_subgroup.insert(0); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; for (unsigned j=0; j<gens.size(); ++j) { int g1 = group.left(g0,gens[j]); if (in_subgroup.find(g1) != in_subgroup.end()) continue; subgroup.push_back(g1); in_subgroup.insert(g1); } } logger.debug() << "subgroup.ord = " << subgroup.size() |0; //build cosets and count ord std::map<int,int> coset; //maps group elements to cosets ord = 0; //used as coset number for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; if (coset.find(g0) != coset.end()) continue; int c0 = ord++; coset[g0] = c0; std::vector<int> members(1, g0); std::vector<int> others(0); for (unsigned i=0; i<members.size(); ++i) { int g1 = members[i]; for (unsigned w=0; w<v_cogens.size(); ++w) { int g2 = group.left(g1, v_cogens[w]); if (coset.find(g2) != coset.end()) continue; coset[g2] = c0; members.push_back(g2); } } } logger.info() << "cosets table built: " << " ord = " << ord |0; //build edge lists std::vector<std::set<int> > neigh(ord); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; int c0 = coset[g0]; for (unsigned w=0; w<e_gens.size(); ++w) { int g1 = group.left(g0, e_gens[w]); Assert (in_subgroup.find(g1) != in_subgroup.end(), "edge leaves subgroup"); int c1 = coset[g1]; if (c0 != c1) neigh[c0].insert(c1); } } // make symmetric for (int c0=0; c0<ord; ++c0) { const std::set<int>& n = neigh[c0]; for (std::set<int>::iterator c1=n.begin(); c1!=n.end(); ++c1) { neigh[*c1].insert(c0); } } // build edge table adj.resize(ord); for (int c=0; c<ord; ++c) { adj[c].insert(adj[c].begin(), neigh[c].begin(), neigh[c].end()); } neigh.clear(); deg = adj[0].size(); logger.info() << "edge table built: deg = " << deg |0; //define faces for (unsigned g=0; g<f_gens.size(); ++g) { const Word& face = f_gens[g]; logger.debug() << "defining faces on " << face |0; Logging::IndentBlock block; //define basic face in group Ring basic(1,0); // g = 0; int g0 = 0; for (unsigned c=0; true; ++c) { g0 = group.left(g0, face[c%face.size()]); if (c >= face.size() and g0 == 0) break; if (in_subgroup.find(g0) != in_subgroup.end() and g0 != basic.back()) { basic.push_back(g0); } } for (unsigned c=0; c<basic.size(); ++c) { logger.debug() << " corner: " << basic[c] |0; } logger.debug() << "sides/face (free) = " << basic.size() |0; //build orbit of basic face std::vector<Ring> faces_g; faces_g.push_back(basic); FaceRecognizer recognized; recognized(basic); for (unsigned i=0; i<faces_g.size(); ++i) { const Ring f = faces_g[i]; for (unsigned j=0; j<gens.size(); ++j) { //right action of group on faces Ring f_j(f.size()); for (unsigned c=0; c<f.size(); ++c) { f_j[c] = group.right(f[c],gens[j]); } //add face if (not recognized(f_j)) { faces_g.push_back(f_j); //logger.debug() << "new face: " << f_j |0; } else { //logger.debug() << "old face: " << f_j|0; } } } //hom face down to quotient graph recognized.clear(); for (unsigned f=0; f<faces_g.size(); ++f) { const Ring face_g = faces_g[f]; Ring face; face.push_back(coset[face_g[0]]); for (unsigned i=1; i<face_g.size(); ++i) { int c = coset[face_g[i]]; if (c != face.back() and c != face[0]) { face.push_back(c); } } if (face.size() < 3) continue; if (not recognized(face)) { faces.push_back(face); } } } ord_f = faces.size(); logger.info() << "faces defined: order = " << ord_f |0; //define vertex coset std::vector<Word> vertex_coset; for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; if (coset[g0]==0) vertex_coset.push_back(group.parse(g0)); } //build geometry std::vector<Mat> gen_reps(gens.size()); points.resize(ord); build_geom(cartan, vertex_coset, gens, v_cogens, weights, gen_reps, points[0]); std::vector<int> pointed(ord,0); pointed[0] = true; logger.debug() << "geometry built" |0; //build point sets std::vector<int> reached(1,0); std::set<int> is_reached; is_reached.insert(0); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = reached[g]; for (unsigned j=0; j<gens.size(); ++j) { int g1 = group.right(g0,gens[j]); if (is_reached.find(g1) == is_reached.end()) { if (not pointed[coset[g1]]) { vect_mult(gen_reps[j], points[coset[g0]], points[coset[g1]]); pointed[coset[g1]] = true; } reached.push_back(g1); is_reached.insert(g1); } } } logger.debug() << "point set built." |0; //build face normals normals.resize(ord_f); for (int f=0; f<ord_f; ++f) { Ring& face = faces[f]; Vect &a = points[face[0]]; Vect &b = points[face[1]]; Vect &c = points[face[2]]; Vect &n = normals[f]; cross4(a,b,c, n); normalize(n); /* Assert1(fabs(inner(a,n)) < 1e-6, "bad normal: <n,a> = " << fabs(inner(a,n))); Assert1(fabs(inner(b,n)) < 1e-6, "bad normal: <n,b> = " << fabs(inner(b,n))); Assert1(fabs(inner(c,n)) < 1e-6, "bad normal: <n,b> = " << fabs(inner(c,n))); */ } logger.debug() << "face normals built." |0; }
bool morpho2d(MorphoFilter<T>* filter, T* in, T* out, int dataSizeX, int dataSizeY, double* kernel, int kernelSizeX, int kernelSizeY) { if (!in || !out || !kernel) return false; if (dataSizeX <= 0 || kernelSizeX <= 0) return false; // find center position of kernel (half of kernel size) int kCenterX = (kernelSizeX >> 1); int kCenterY = (kernelSizeY >> 1); // init working pointers T* inPtr = &in[dataSizeX * kCenterY + kCenterX]; // note that it is shifted (kCenterX, kCenterY) T* inPtr2 = inPtr; T* outPtr = out; double* kPtr = kernel; std::vector<T> neigh(kernelSizeX*kernelSizeY); // start convolution for (int i = 0; i < dataSizeY; ++i) { // number of rows // compute the range of convolution, the current row of kernel should be between these int rowMax = i + kCenterY; int rowMin = i - dataSizeY + kCenterY; for (int j = 0; j < dataSizeX; ++j) { // number of columns // compute the range of convolution, the current column of kernel should be between these int colMax = j + kCenterX; int colMin = j - dataSizeX + kCenterX; *outPtr = 0; // set to 0 before accumulate // flip the kernel and traverse all the kernel values int cnt = 0; for (int m = 0; m < kernelSizeY; ++m) { // kernel rows // check if the index is out of bound of input array if (m <= rowMax && m > rowMin) { for (int n = 0; n < kernelSizeX; ++n) { // check the boundary of array if (n <= colMax && n > colMin) { neigh[cnt++] = *(inPtr - n); } ++kPtr; // next kernel } // determine new pixel value from neighbors if (cnt) *outPtr = filter->processNeighborhood(neigh); } else kPtr += kernelSizeX; // out of bound, move to next row of kernel inPtr -= dataSizeX; // move input data 1 raw up } kPtr = kernel; // reset kernel to (0,0) inPtr = ++inPtr2; // next input ++outPtr; // next output } } return true; }
Family operator()( int color, const Space& sub ) { Space base, margin; Family adjs; for ( typename Space::const_iterator it = base_.begin() ; it != base_.end(); ++it ) { typename Space::const_point pt( it ); if ( color_[ pt.index ] == color ) base.join( pt.element ); } for ( typename Space::const_iterator it = base.begin() ; it != base.end(); ++it ) { typename Space::const_point pt0( it ); #ifdef ELAI_USE_C11 const Space&& adj = std::move( adjacent_( pt0.element ) ); #else const Space adj = adjacent_( pt0.element ); #endif Neighbour neigh( Element( pt0.element, color ) ); for ( typename Space::const_iterator jt = adj.begin() ; jt != adj.end(); ++jt ) { typename Space::const_point pt( jt ); const Element pt1( pt.element, color ); if ( !base.contain( pt.element ) && !margin.contain( pt.element ) ) margin.join( pt.element, Element( pt.element, color ) ); // ( BASE, RECOLORED ) if ( !sub.contain( pt1 ) ) continue; neigh.join( pt1 ); } adjs.join( neigh ); } for ( typename Space::const_marginal_iterator it = margin.internal_begin() ; it != margin.internal_end(); ++it ) { typename Space::const_internal_point pt0( it ); #ifdef ELAI_USE_C11 const Space&& adj = std::move( adjacent_( pt0.element ) ); #else const Space adj = adjacent_( pt0.internal ); // BASE ELEMENT #endif Neighbour neigh( pt0.external ); // RECOLORED ELEMENT for ( typename Space::const_iterator jt = adj.begin(); jt != adj.end(); ++jt ) { typename Space::const_point pt( jt ); const Element pt1( pt.element, color ); if ( !sub.contain( pt1 ) ) continue; neigh.join( pt1 ); } adjs.join( neigh ); } return adjs; }
// Main programm int main (int argc, char *argv[]) { Search_settings sett; Command_line_opts opts; Search_range s_range; Aux_arrays aux_arr; double *F; // F-statistic array int i, j, r, c, a, b, g; int d, o, m, k; int bins = 2, ROW, dim = 4; // neighbourhood of point will be divide into defined number of bins double pc[4]; // % define neighbourhood around each parameter for initial grid double pc2[4]; // % define neighbourhood around each parameter for direct maximum search (MADS & Simplex) double tol = 1e-10; // double delta = 1e-5; // initial step in MADS function // double *results; // Vector with results from Fstatnet function // double *maximum; // True maximum of Fstat // double results_max[11]; double s1, s2, s3, s4; double sgnlo[4]; double **arr; // arr[ROW][COL], arrg[ROW][COL]; double nSource[3]; double sinalt, cosalt, sindelt, cosdelt; double F_min; char path[512]; double x, y; ROW = pow((bins+1),4); #ifdef YEPPP yepLibrary_Init(); Yep64f *results_max = (Yep64f*)malloc(sizeof(Yep64f)*11); Yep64f *results_first = (Yep64f*)malloc(sizeof(Yep64f)*11); Yep64f *results = (Yep64f*)malloc(sizeof(Yep64f)*11); Yep64f *maximum = (Yep64f*)malloc(sizeof(Yep64f)*11); // Yep64f *sgnlo = (Yep64f*)malloc(sizeof(Yep64f)*4); // Yep64f *nSource = (Yep64f*)malloc(sizeof(Yep64f)*3); Yep64f *mean = (Yep64f*)malloc(sizeof(Yep64f)*4); enum YepStatus status; #endif pc[0] = 0.015; pc[1] = 0.015; pc[2] = 0.015; pc[3] = 0.015; for (i = 0; i < 4; i++){ pc2[i] = 2*pc[i]/bins; } // Time tests double tdiff; clock_t tstart, tend; // Command line options handle_opts(&sett, &opts, argc, argv); // Output data handling /* struct stat buffer; if (stat(opts.prefix, &buffer) == -1) { if (errno == ENOENT) { // Output directory apparently does not exist, try to create one if(mkdir(opts.prefix, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) { perror (opts.prefix); return 1; } } else { // can't access output directory perror (opts.prefix); return 1; } } */ sprintf(path, "%s/candidates.coi", opts.dtaprefix); //Glue function if(strlen(opts.glue)) { glue(&opts); sprintf(opts.dtaprefix, "./data_total"); sprintf(opts.dtaprefix, "%s/followup_total_data", opts.prefix); opts.ident = 000; } FILE *coi; int z; if ((coi = fopen(path, "r")) != NULL) { // while(!feof(coi)) { /* if(!fread(&w, sizeof(unsigned short int), 1, coi)) { break; } fread(&mean, sizeof(float), 5, coi); fread(&fra, sizeof(unsigned short int), w, coi); fread(&ops, sizeof(int), w, coi); if((fread(&mean, sizeof(float), 4, coi)) == 4){ */ while(fscanf(coi, "%le %le %le %le", &mean[0], &mean[1], &mean[2], &mean[3]) == 4){ //Time test // tstart = clock(); arr = matrix(ROW, 4); //Function neighbourhood - generating grid around point arr = neigh(mean, pc, bins); // Output data handling /* struct stat buffer; if (stat(opts.prefix, &buffer) == -1) { if (errno == ENOENT) { // Output directory apparently does not exist, try to create one if(mkdir(opts.prefix, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) { perror (opts.prefix); return 1; } } else { // can't access output directory perror (opts.prefix); return 1; } } */ // Grid data if(strlen(opts.addsig)) { read_grid(&sett, &opts); } // Search settings search_settings(&sett); // Detector network settings detectors_settings(&sett, &opts); // Array initialization init_arrays(&sett, &opts, &aux_arr, &F); // Amplitude modulation functions for each detector for(i=0; i<sett.nifo; i++) rogcvir(&ifo[i]); // Adding signal from file if(strlen(opts.addsig)) { add_signal(&sett, &opts, &aux_arr, &s_range); } // Setting number of using threads (not required) omp_set_num_threads(1); results_max[5] = 0.; // ifo zostaje shared // ifo....shft i ifo....xdatm{a,b] prerobić na lokalne tablice w fstatnet // w regionie parallel wprowadzić tablice private aa i bb ; alokować i przekazywać je jako argumenty do fstatnet i amoeba // Main loop - over all parameters + parallelisation #pragma omp parallel default(shared) private(d, i, sgnlo, sinalt, cosalt, sindelt, cosdelt, nSource, results, maximum) { double **sigaa, **sigbb; // aa[nifo][N] sigaa = matrix(sett.nifo, sett.N); sigbb = matrix(sett.nifo, sett.N); #pragma omp for for (d = 0; d < ROW; ++d){ for (i = 0; i < 4; i++){ sgnlo[i] = arr[d][i]; // sgnlo[i] = mean[i]; } sinalt = sin(sgnlo[3]); cosalt = cos(sgnlo[3]); sindelt = sin(sgnlo[2]); cosdelt = cos(sgnlo[2]); nSource[0] = cosalt*cosdelt; nSource[1] = sinalt*cosdelt; nSource[2] = sindelt; for (i = 0; i < sett.nifo; ++i){ modvir(sinalt, cosalt, sindelt, cosdelt, sett.N, &ifo[i], &aux_arr, sigaa[i], sigbb[i]); } // F-statistic in given point results = Fstatnet(&sett, sgnlo, nSource, sigaa, sigbb); //printf("Fstatnet: %le %le %le %le %le %le\n", results[6], results[7], results[8], results[9], results[5], results[4]); #pragma omp critical if(results[5] < results_max[5]){ for (i = 0; i < 11; i++){ results_max[i] = results[i]; } } // Maximum search using simplex algorithm if(opts.simplex_flag){ // puts("Simplex"); maximum = amoeba(&sett, &aux_arr, sgnlo, nSource, results, dim, tol, pc2, sigaa, sigbb); printf("Amoeba: %le %le %le %le %le %le\n", maximum[6], maximum[7], maximum[8], maximum[9], maximum[5], maximum[4]); // Maximum value in points searching #pragma omp critical if(maximum[5] < results_max[5]){ for (i = 0; i < 11; i++){ results_max[i] = maximum[i]; } } } //simplex } // d - main outside loop free_matrix(sigaa, sett.nifo, sett.N); free_matrix(sigbb, sett.nifo, sett.N); } //pragma for(g = 0; g < 11; g++) results_first[g] = results_max[g]; // Maximum search using MADS algorithm if(opts.mads_flag) { // puts("MADS"); maximum = MADS(&sett, &aux_arr, results_max, mean, tol, pc2, bins); } //Time test // tend = clock(); // tdiff = (tend - tstart)/(double)CLOCKS_PER_SEC; printf("%le %le %le %le %le %le\n", results_max[6], results_max[7], results_max[8], results_max[9], results_max[5], results_max[4]); } // while fread coi // } } //if coi else { perror (path); return 1; } // Output information /* puts("**********************************************************************"); printf("*** Maximum value of F-statistic for grid is : (-)%.8le ***\n", -results_first[5]); printf("Sgnlo: %.8le %.8le %.8le %.8le\n", results_first[6], results_first[7], results_first[8], results_first[9]); printf("Amplitudes: %.8le %.8le %.8le %.8le\n", results_first[0], results_first[1], results_first[2], results_first[3]); printf("Signal-to-noise ratio: %.8le\n", results_first[4]); printf("Signal-to-noise ratio from estimated amplitudes (for h0 = 1): %.8le\n", results_first[10]); puts("**********************************************************************"); if((opts.mads_flag)||(opts.simplex_flag)){ printf("*** True maximum is : (-)%.8le ***\n", -maximum[5]); printf("Sgnlo for true maximum: %.8le %.8le %.8le %.8le\n", maximum[6], maximum[7], maximum[8], maximum[9]); printf("Amplitudes for true maximum: %.8le %.8le %.8le %.8le\n", maximum[0], maximum[1], maximum[2], maximum[3]); printf("Signal-to-noise ratio for true maximum: %.8le\n", maximum[4]); printf("Signal-to-noise ratio from estimated amplitudes (for h0 = 1) for true maximum: %.8le\n", maximum[10]); puts("**********************************************************************"); }*/ // Cleanup & memory free free(results_max); free(results_first); free(results); free(maximum); free(mean); free_matrix(arr, ROW, 4); cleanup_followup(&sett, &opts, &s_range, &aux_arr, F); return 0; }