示例#1
0
      void apply(const OperandType &operand, ResultType result) const
      {
        super::apply(operand, result);

        ResultType iterand = result;
        iterand.clear();
        solve_bicgstab(
            m_matrix, 
            m_preconditioner, 
            iterand, 
            operand, 
            this->m_tolerance,
            this->m_maxIterations, 
            const_cast<unsigned *>(&this->m_lastIterationCount), 
            this->m_debugLevel);
        result.assign(iterand);
      }
示例#2
0
int main(int argc, char * argv[]) {
  using namespace fbi;
  using namespace boost::posix_time;
#ifdef __LIBFBI_USE_MULTITHREADING__
  std::cout << "Multithreading enabled" << std::endl;
#endif
  ProgramOptions options;
  if (!parseProgramOptions(argc, argv, options)) {
    return 0;
  }
  typedef SetA<Centroid,1,0 > SetType;
  typedef SetType::ResultType ResultType;
  typedef unsigned int LabelType;

  ptime start = microsec_clock::universal_time();
  
  SNSplitter<SetType, LabelType> splitter(options);

  CentroidBoxGenerator gen(10,1);
  ResultType test = std::vector<std::vector<unsigned int> >();
  boost::function<ResultType(std::deque<Centroid>)> boostFunctor =
  boost::bind(
  &SetType::intersect<const std::deque<Centroid>&,const CentroidBoxGenerator&, const CentroidBoxGenerator&>
  , _1, gen, gen);
  
  std::cout << "Looking for overlaps" << std::endl;
  ResultType fullAdjList = splitter.findOverlaps(boostFunctor);
  ptime end = microsec_clock::universal_time();
  time_duration td = end - start;
  std::cout << "elapsed time in seconds: " 
    << td.total_seconds()
    << std::endl;
  std::cout << "finding connected components... ";
  std::vector<LabelType> labels;
  unsigned int nComponents = findConnectedComponents(fullAdjList, labels);
  fullAdjList.clear();
  ResultType().swap(fullAdjList);

  std::cout << "Rereading centroids file" << std::endl;
  std::vector<Centroid> centroids;
  std::ifstream ifs(options.inputfileName_);
  std::string str;
  while (std::getline(ifs, str)) {
    parseString(str, centroids, 0);
  }
  ifs.close();

  std::vector<unsigned int> counter(nComponents);
  std::cout << "Creating Xics" << std::endl;
  std::vector<Xic> xics = createXicVector(centroids.begin(), centroids.end(), labels.begin(), labels.end(), counter);

  std::ofstream ofs(options.outputfileName_.c_str());


  std::cout << "Writing xics to outputfile" << std::endl;
  for (std::vector<Xic>::size_type i = 0; i < xics.size(); ++i) {
    if (counter[i] >= options.minClusterSize_) {
      ofs << xics[i] << "\t" << counter[i] <<std::endl;
    }
  }
}