コード例 #1
0
        simple_polynomial_type const generate_polynomial( size_matrix_type const& ar, size_type row, size_type col, coefficient<value_type> const& coef, Iterator diag_begin, zero_set_type const& zero_set, Coef_Extractor const& extractor ) const
        {
            simple_polynomial_type answer;
            size_type const n = ar.row();
            assert( ar.row() == ar.col() );
            assert( row < n );
            assert( col < n );

            //C1 part
            size_type const ij_index = ar[row][col];
            size_type const s_ij_index = make_index( ij_index, 0 );
            auto const& rho_ij = make_term<value_type, simple_symbol_type>( simple_symbol_type { value_type{}, s_ij_index } );
            answer += rho_ij * extractor( coef( row, col ) );

            //C2 part
            for ( size_type k = 0; k != n; ++k )
            {
                // ignore if is in zero set
                size_type const ik_index = ar[row][k];
                size_type const kj_index = ar[k][col];
                if ( zero_set.find( ik_index ) != zero_set.end() || zero_set.find( kj_index ) != zero_set.end() )
                {
                    continue;
                }

                value_type c_ikj = extractor( coef( row, k, col ) );

                // it is safe here as we do not use (row==col) intensity
                // i == k != j
                if ( row == k )
                {
                    c_ikj *= *( diag_begin + k );
                    size_type s_kj_index = make_index( kj_index, 0 );
                    simple_term_type const& t_kj = make_term<value_type, simple_symbol_type>( simple_symbol_type { value_type{}, s_kj_index } );
                    answer +=  c_ikj * t_kj;
                    continue;
                }
                // i != k == j
                if ( col == k )
                {
                    c_ikj *= *( diag_begin + k );
                    size_type s_ik_index = make_index( ik_index, 0 );
                    simple_term_type const& t_ik = make_term<value_type, simple_symbol_type>( simple_symbol_type { value_type{}, s_ik_index } );
                    answer +=  c_ikj * t_ik;
                    continue;
                }
                // i != k != j
                size_type const s_ikj_index = make_index( ik_index, kj_index );
                simple_term_type const& t_ikj = make_term<value_type, simple_symbol_type>( simple_symbol_type { value_type{}, s_ikj_index } );
                answer += c_ikj * t_ikj;
            }

            return answer;
        }
コード例 #2
0
ファイル: tyindex.c プロジェクト: faircreek/tydemux
int create_index_files(fsid_index_t * fsid_index,dir_index_t * dir_index, int files) {

	fsid_index_t * tmp_fsid_index;
	int error;

	tmp_fsid_index = fsid_index;

	if(!files) {
		files = 1;
	} else {
		files = 0;
	}

	error = 0;
	while(tmp_fsid_index) {
		if((tmp_fsid_index->state && !index_present(tmp_fsid_index, dir_index)) ||
			(tmp_fsid_index->state && files)) {
			printf("Need to make %i index \n", tmp_fsid_index->fsid);
			error = make_index(tmp_fsid_index);
		}
		tmp_fsid_index = tmp_fsid_index->next;
	}


	if(error) {
		return(0);
	} else {
		return(1);
	}

}
コード例 #3
0
ファイル: archive.cpp プロジェクト: landswellsong/FAR
UInt32 Archive::find_dir(const wstring& path) {
  if (file_list.empty())
    make_index();

  ArcFileInfo dir_info;
  dir_info.is_dir = true;
  dir_info.parent = c_root_index;
  size_t begin_pos = 0;
  while (begin_pos < path.size()) {
    size_t end_pos = begin_pos;
    while (end_pos < path.size() && !is_slash(path[end_pos])) end_pos++;
    if (end_pos != begin_pos) {
      dir_info.name.assign(path.data() + begin_pos, end_pos - begin_pos);
      FileIndexRange fi_range = equal_range(file_list_index.begin(), file_list_index.end(), -1, [&] (UInt32 left, UInt32 right) -> bool {
        const ArcFileInfo& fi_left = left == -1 ? dir_info : file_list[left];
        const ArcFileInfo& fi_right = right == -1 ? dir_info : file_list[right];
        return fi_left < fi_right;
      });
      if (fi_range.first == fi_range.second)
        FAIL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND));
      dir_info.parent = *fi_range.first;
    }
    begin_pos = end_pos + 1;
  }
  return dir_info.parent;
}
コード例 #4
0
        // ( low, high ) -> ( low | high )
        size_type make_index( size_type low = 0, size_type high = 0 ) const
        {
            if ( low > high )
            {
                return make_index( high, low );
            }

            return low << 32 | high;
        }
コード例 #5
0
int Scene_Gang_Manager::matched_handle(int64_t gang_id1, int64_t gang_id2) {
	Time_Value now = Time_Value::gettimeofday();
	Date_Time dt(now);
//	dt.hour(20);
//	dt.minute(30);
	dt.second(0);
	dt.microsec(0);

	int8_t index = make_index() - 1;
	int64_t scene_index = SCENE_GANG_GLOBAL_MANAGER->make_scene_index();
	Gang_War_Matched_Gangs_Pair matched_gangs;
	matched_gangs.matched_pair.first = gang_id1;
	matched_gangs.matched_pair.second = gang_id2;
	matched_gangs.match_time.sec(dt.time_sec());
	matched_gangs.matched_index = index;
	matched_gangs.scene_index = scene_index;
	gang_vec_.push_back(matched_gangs);
	scene_index_gang_map_.insert(std::make_pair(scene_index, matched_gangs));

	Gang_War_Matched_Gang_Info info;
	info.matched_index = index;
	info.scene_index = scene_index;
	info.match_time = matched_gangs.match_time;
	info.camp = CAMP_RED;
	if (gang_id1 > 0) {
		info.force = 0;
		Gang_DB_View* gdv = gang_view_by_id(gang_id1);
		if (gdv) {
			info.force = gdv->force_total;
		}
		info.gang_name = gang_name(gang_id1);
		info.zone.clear();
		std::string *zone = find_zone(gang_id1);
		if (zone) {
			info.zone = *zone;
		}
		gang_index_map_.insert(std::make_pair(gang_id1, info));
	}
	info.camp = CAMP_BLUE;
	if (gang_id2 > 0) {
		info.force = 0;
		Gang_DB_View* gdv = gang_view_by_id(gang_id2);
		if (gdv) {
			info.force = gdv->force_total;
		}
		info.gang_name = gang_name(gang_id2);
		info.zone.clear();
		std::string *zone = find_zone(gang_id2);
		if (zone) {
			info.zone = *zone;
		}
		gang_index_map_.insert(std::make_pair(gang_id2, info));
	}
	return 0;
}
コード例 #6
0
ファイル: archive.cpp プロジェクト: landswellsong/FAR
wstring Archive::get_path(UInt32 index) {
  if (file_list.empty())
    make_index();

  wstring file_path = file_list[index].name;
  UInt32 parent = file_list[index].parent;
  while (parent != c_root_index) {
    file_path.insert(0, 1, L'\\').insert(0, file_list[parent].name);
    parent = file_list[parent].parent;
  }
  return file_path;
}
コード例 #7
0
ファイル: archive.cpp プロジェクト: landswellsong/FAR
FindData Archive::get_file_info(UInt32 index) {
  if (file_list.empty())
    make_index();

  FindData file_info;
  memzero(file_info);
  wcscpy(file_info.cFileName, file_list[index].name.c_str());
  file_info.dwFileAttributes = get_attr(index);
  file_info.set_size(get_size(index));
  file_info.ftCreationTime = get_ctime(index);
  file_info.ftLastWriteTime = get_mtime(index);
  file_info.ftLastAccessTime = get_atime(index);
  return file_info;
}
コード例 #8
0
ファイル: archive.cpp プロジェクト: landswellsong/FAR
FileIndexRange Archive::get_dir_list(UInt32 dir_index) {
  if (file_list.empty())
    make_index();

  ArcFileInfo file_info;
  file_info.parent = dir_index;
  FileIndexRange index_range = equal_range(file_list_index.begin(), file_list_index.end(), -1, [&] (UInt32 left, UInt32 right) -> bool {
    const ArcFileInfo& fi_left = left == -1 ? file_info : file_list[left];
    const ArcFileInfo& fi_right = right == -1 ? file_info : file_list[right];
    return fi_left.parent < fi_right.parent;
  });

  return index_range;
}
コード例 #9
0
int main()
{
    clean_up();
    build_global_data();
    make_index();


    string name;
    FILE* tmp_fp=fopen("tmp.txt","r");
    char buf[10086];
    while(fscanf(tmp_fp,"%s",buf)==1)
    {
        name=buf;
        make_mask(name);
    }
    fclose(tmp_fp);
    pack_up();
    return 0;
}
コード例 #10
0
    value_type const& operator()(size_type r, size_type c) const
    {
        // pre: data != null pointer
        DCS_ASSERT(
            data_,
            throw ::std::runtime_error("[dcs::des::cloud::config::numeric_matrix::()] Data not defined.")
        );
        // pre: r < #rows
        DCS_ASSERT(
            r < nr_,
            throw ::std::invalid_argument("[dcs::des::cloud::config::numeric_matrix::()] Row out of range.")
        );
        // pre: c < #columns
        DCS_ASSERT(
            c < nc_,
            throw ::std::invalid_argument("[dcs::des::cloud::config::numeric_matrix::()] Columns out of range.")
        );

        return data_[make_index(r,c)];
    }
コード例 #11
0
ファイル: directed_graph.hpp プロジェクト: 8573/anura
 std::pair<edge_descriptor, bool>
 add_edge(vertex_descriptor u, vertex_descriptor v)
 { return make_index(boost::add_edge(u, v, m_graph)); }
コード例 #12
0
ファイル: directed_graph.hpp プロジェクト: 8573/anura
 vertex_descriptor add_vertex(vertex_property_type const& p)
 { return make_index(boost::add_vertex(internal_vertex_property(0u, p), m_graph)); }
コード例 #13
0
ファイル: directed_graph.hpp プロジェクト: 8573/anura
 vertex_descriptor add_vertex()
 { return make_index(boost::add_vertex(m_graph)); }
コード例 #14
0
ファイル: trainEngine.cpp プロジェクト: terry2012/magictrain
/* link response packets to request packets */
void TrainEngine::linking()
{
    Packet* p = NULL;
    int index;

    request_ = new Packet*[trainSize];
    response_ = new Packet*[trainSize];

    for (int i=0; i<trainSize; i++)
    {
        request_[i] = NULL;
        response_[i] = NULL;
    }

    while ((p = globalBuf->pop(TIMEOUT)) != NULL)
    {
        index = make_index(p);
        if (index >= 0 && index < trainSize)
        {
            if (check_dir(p) == 0)
            {
                if (!request_[index])
                {
                    request_[index] = p;
                    request_cnt_++;
                }
                else
                {
                    logger->PrintDebug("[%s:%d] Duplicated request packets!\n", __FILE__, __LINE__);
                    if (conf_->get_debug())
                    {
                        p->print();
                    }
                }
            }
            else if (check_dir(p) == 1)
            {
                if (!response_[index])
                {
                    response_[index] = p;
                    response_cnt_++;
                }
                else
                {
                    logger->PrintDebug("[%s:%d] Duplicated response packets!\n", __FILE__, __LINE__);
                    if (conf_->get_debug())
                    {
                        p->print();
                    }
                }
            }
        }
        else if (index == -1)
        {
            non_exist_cnt++;
            delete p;
        }
        else
        {
            delete p;
        }
    }

    // debug infomation
    if (conf_->get_debug())
    {
        for (int i=0; i<trainSize; i++)
        {
            if (request_[i])
            {
                request_[i]->print();
            }
            if (response_[i])
            {
                response_[i]->print();
            }
            std::cout << std::endl;
        }
    }
}
コード例 #15
0
ファイル: main.c プロジェクト: kybernetyk/Blogtard
int main (int argc, char **argv)
{
	make_index ();
	make_rss ();
	return 0;
}
コード例 #16
0
ファイル: directed_graph.hpp プロジェクト: 8573/anura
 std::pair<edge_descriptor, bool>
 add_edge(vertex_descriptor u, vertex_descriptor v, edge_property_type const& p)
 { return make_index(boost::add_edge(u, v, internal_edge_property(0u, p), m_graph)); }
コード例 #17
0
ファイル: baseline_reml.cpp プロジェクト: cran/BayesXsrc
baseline_reml::baseline_reml(MCMCoptions * o,
              const datamatrix & d, const datamatrix & leftint,
              const datamatrix & lefttrunc, const unsigned & nrk,
              const unsigned & degr, const unsigned & tgr, const unsigned & nrq,
              const unsigned & nrb, const knotpos & kp, const fieldtype & ft,
              const ST::string & ti, const ST::string & fp,
              const ST::string & pres, const double & l, const double & sl,
              const knotpos & gp, const int & gs, const bool & catsp, const double & rv)
  : spline_basis(o,d,nrk,degr,kp,ft,ti,fp,pres,l,sl,catsp,0.0,0.0,0.0,0.0,gs,rv)
  {
  unsigned i,j,k;

  baseline=true;
  varcoeff=false;

//  refcheck=false;

  gridpos = gp;
  double tmax=d.max(0);

  if(gridpos == MCMC::equidistant)
    {
    tgrid = tgr;
    tvalues = datamatrix(tgrid+1,1);
    tstep = tmax / tgrid;
    for(i=0;i<tvalues.rows();i++)
      tvalues(i,0) = i*tstep;
    }
  else if(gridpos == MCMC::quantiles)
    {
    tgrid = nrq*nrb;
    tvalues = datamatrix(tgrid+1,1);
    nrquant = nrq;
    nrbetween = nrb;
    datamatrix tquantiles = datamatrix(nrquant+1,1,0);
    for(i=1; i<nrquant; i++)
      {
      tquantiles(i,0) = d.quantile(((double)i/nrquant)*100,0);
      }
    tquantiles(nrquant,0) = tmax;

    double intmax, intmin, intstep;
    for(i=0; i<nrquant; i++)
      {
      intmin=tquantiles(i,0);
      intmax=tquantiles(i+1,0);
      intstep=(intmax-intmin)/nrbetween;
      for(j=0; j<nrbetween; j++)
        {
        tvalues(i*nrbetween+j,0) = intmin + j*intstep;
        }
      }
    tvalues(tgrid,0) = tmax;
    }
  else
    {
    make_index(d);
    vector<int>::iterator freqwork = freqoutput.begin();
    int * workindex = index.getV();
    tvalues = datamatrix(nrdiffobs,1,0);
    for(j=0;j<d.rows();j++,freqwork++,workindex++)
      if(freqwork==freqoutput.begin() || *freqwork!=*(freqwork-1))
        tvalues(*freqwork,0) = d(*workindex,0);
    }

  tsteps = datamatrix(tvalues.rows()-1,1,0);
  for(i=0; i<tsteps.rows(); i++)
    tsteps(i,0) = tvalues(i+1,0)-tvalues(i,0);

  interact_var = datamatrix(d.rows(),1,1);

  datamatrix betahelp(nrpar,1,0);
  DG = datamatrix(tvalues.rows(),degree+1,0);
  DGfirst = vector<int>(tvalues.rows());

  for(i=0;i<tvalues.rows();i++)
    {
    betahelp.assign( bspline(tvalues(i,0)) );
    j=degree+1;
    while(knot[j] <= tvalues(i,0) && j<nrknots+degree)
      j++;
    for(k=0;k<degree+1;k++)
      DG(i,k) = betahelp(k+j-(degree+1),0);
    DGfirst[i] = j-(degree+1);
    }

  tleft = vector<unsigned>(d.rows(),0);
  tright = vector<unsigned>(d.rows(),1);
  ttrunc = vector<unsigned>(d.rows(),0);

  // indices for truncation times

  if(lefttrunc.rows()>1)
    {
    for(i=0; i<lefttrunc.rows(); i++)
      {
      j=1;
      while(j<tvalues.rows() && tvalues(j,0) < lefttrunc(i,0))
        {
        ttrunc[i]++;
        j++;
        }
      }
    }

  for(i=0; i<d.rows(); i++)
    {
    j=0;
    while(j<tvalues.rows()-2 && tvalues(j,0)<d(i,0))
      {
      tright[i]++;
      j++;
      }
    }

  if(leftint.rows()>1)
    {
    for(i=0; i<d.rows(); i++)
      {
      if( leftint(i,0) < d(i,0))
        {
        j=0;
        while(j<tvalues.rows()-1 && tvalues(j,0)<leftint(i,0))
          {
          tleft[i]++;
          j++;
          }
        }
      else if(leftint(i,0)> d(i,0))
        {
        tleft[i] = tright[i]+1;
        }
      else
        {
        tleft[i] = tright[i];
        }
      }
    }
  else
    {
    for(i=0; i<d.rows(); i++)
      {
      tleft[i] = tright[i];
      }
    }

  }
コード例 #18
0
ファイル: search.cpp プロジェクト: he3210/searchEngine
 CWord_correct::CWord_correct(const char*  path):dic_path(path),r_index(HASH_BASE)
 {
     make_index(r_index,dic_path);
     std::cout<<"r_index has established!"<<std::endl;
 }
コード例 #19
0
    numeric_matrix(size_type r, size_type c, ForwardIterT data_first, ForwardIterT data_last, bool byrow)
        : nr_(r),
          nc_(c),
          data_(0)
    {
        // pre: #rows > 0
        DCS_ASSERT(
            nr_ > 0,
            throw ::std::invalid_argument("[dcs::des::cloud::config::numeric_matrix::ctor] Invalid number of rows.")
        );
        // pre: #columns > 0
        DCS_ASSERT(
            nc_ > 0,
            throw ::std::invalid_argument("[dcs::des::cloud::config::numeric_matrix::ctor] Invalid number of columns.")
        );
        // pre: size == distance of data_last from data_first
        DCS_ASSERT(
            static_cast< ::std::ptrdiff_t >(nr_*nc_) == ::std::distance(data_first, data_last),
            throw ::std::invalid_argument("[dcs::des::cloud::config::numeric_matrix::ctor] Unsufficient number of data.")
        );

        size_type sz = nr_*nc_;
        //::std::ptrdiff_t datasz = ::std::distance(data_first, data_last);

        data_ = new value_type[sz];

        if (byrow)
        {
            for (size_type r = 0; r < nr_; ++r)
            {
                for (size_type c = 0; c < nc_; ++c)
                {
                    if (data_first != data_last)
                    {
                        data_[make_index(r,c)] = *data_first;
                        ++data_first;
                    }
                    else
                    {
                        data_[make_index(r,c)] = value_type/*zero*/();
                    }
                }
            }
        }
        else
        {
            for (size_type c = 0; c < nc_; ++c)
            {
                for (size_type r = 0; r < nr_; ++r)
                {
                    if (data_first != data_last)
                    {
                        data_[make_index(r,c)] = *data_first;
                        ++data_first;
                    }
                    else
                    {
                        data_[make_index(r,c)] = value_type/*zero*/();
                    }
                }
            }
        }
    }
コード例 #20
0
ファイル: main.c プロジェクト: HrantOhanyan/unsis
int main(int argc, char **argv)
{
  char **infiles;
  char *outfile;
  int nfiles;
  int nogo;
  int errs;
  int reportcols;
  int debug;

  /*
   * Set up initial (default) parameters.
   */
  infiles = mknewa(char *, argc);
  outfile = NULL;
  nfiles = 0;
  nogo = errs = FALSE;
  reportcols = 0;
  debug = 0;

  if (argc == 1)
  {
    usage();
    exit(EXIT_SUCCESS);
  }

  /*
   * Parse command line arguments.
   */
  while (--argc)
  {
    char *p = *++argv;
    if (*p == '-')
    {
      /*
       * An option.
       */
      while (p && *++p)
      {
        char c = *p;
        switch (c)
        {
        case '-':
          /*
           * Long option.
           */
          {
            char *opt, *val;
            opt = p++;          /* opt will have _one_ leading - */
            while (*p && *p != '=')
              p++;              /* find end of option */
            if (*p == '=')
            {
              *p++ = '\0';
              val = p;
            } else
              val = NULL;
            if (!strcmp(opt, "-version"))
            {
              showversion();
              nogo = TRUE;
            } else if (!strcmp(opt, "-licence") ||
                       !strcmp(opt, "-license"))
            {
              licence();
              nogo = TRUE;
            } else if (!strcmp(opt, "-output"))
            {
              if (!val)
                errs = TRUE, error(err_optnoarg, opt);
              else
                outfile = val;
            } else if (!strcmp(opt, "-precise"))
            {
              reportcols = 1;
            } else
            {
              errs = TRUE, error(err_nosuchopt, opt);
            }
          }
          p = NULL;
          break;
        case 'V':
        case 'L':
        case 'P':
        case 'd':
          /*
           * Option requiring no parameter.
           */
          switch (c)
          {
          case 'V':
            showversion();
            nogo = TRUE;
            break;
          case 'L':
            licence();
            nogo = TRUE;
            break;
          case 'P':
            reportcols = 1;
            break;
          case 'd':
            debug = TRUE;
            break;
          }
          break;
        case 'o':
          /*
           * Option requiring parameter.
           */
          p++;
          if (!*p && argc > 1)
            --argc, p = *++argv;
          else if (!*p)
          {
            char opt[2];
            opt[0] = c;
            opt[1] = '\0';
            errs = TRUE, error(err_optnoarg, opt);
          }
          /*
           * Now c is the option and p is the parameter.
           */
          switch (c)
          {
          case 'o':
            outfile = p;
            break;
          }
          p = NULL;             /* prevent continued processing */
          break;
        default:
          /*
           * Unrecognised option.
           */
          {
            char opt[2];
            opt[0] = c;
            opt[1] = '\0';
            errs = TRUE, error(err_nosuchopt, opt);
          }
        }
      }
    } else
    {
      /*
       * A non-option argument.
       */
      infiles[nfiles++] = p;
    }
  }

  if (errs)
    exit(EXIT_FAILURE);
  if (nogo)
    exit(EXIT_SUCCESS);

  /*
   * Do the work.
   */
  if (nfiles == 0)
  {
    error(err_noinput);
    usage();
    exit(EXIT_FAILURE);
  }

  {
    input in;
    paragraph *sourceform, *p;
    indexdata *idx;
    keywordlist *keywords;

    in.filenames = infiles;
    in.nfiles = nfiles;
    in.currfp = NULL;
    in.currindex = 0;
    in.npushback = in.pushbacksize = 0;
    in.pushback = NULL;
    in.reportcols = reportcols;
    in.stack = NULL;

    idx = make_index();

    sourceform = read_input(&in, idx);
    if (!sourceform)
      exit(EXIT_FAILURE);

    sfree(in.pushback);

    mark_attr_ends(sourceform);

    sfree(infiles);

    keywords = get_keywords(sourceform);
    if (!keywords)
      exit(EXIT_FAILURE);
    gen_citations(sourceform, keywords);
    subst_keywords(sourceform, keywords);

    for (p = sourceform; p; p = p->next)
      if (p->type == para_IM)
        index_merge(idx, TRUE, p->keyword, p->words);

    build_index(idx);


    if (debug)
    {
      index_debug(idx);
      dbg_prtkws(keywords);
      dbg_prtsource(sourceform);
    }

    xhtml_backend(sourceform, keywords, idx);

    free_para_list(sourceform);
    free_keywords(keywords);
    cleanup_index(idx);
  }

  return 0;
}
コード例 #21
0
ファイル: pbm2png.c プロジェクト: engine12/links
/*
 * Parameters: <hundred_dpi> <basename_> <titlestring> <bottom_html_code>
 * <pageoffset> [first page number]
 */
int
main(int argc, char **argv)
{
        int a,z;
 
        if (argc<7){
                fprintf(stderr,"Usage: pbm2png <hundred_dpi> <basename_> <titlestring> <bottom_html_code> <pageoffset> <ifname> [starting_filenumber]\n");
        return 0;
        }
        dpi=atof(argv[1])/10;
        ppm=dpi*1000/25.4;
        basename_=argv[2];
        titlestring=argv[3];
	bottom=argv[4];
        pageoffset=atol(argv[5]);
        filename=argv[6];
	again0:
        ifd=open(filename,O_RDONLY);
	if (ifd<0){
		if (errno==EAGAIN||errno==EINTR||errno==EWOULDBLOCK) goto
			again0;
		else {
			perror("");
			exit(1);
		}
	}
        fprintf(stderr,"filename %s, %d\n",filename,ifd);
        if (argc>=8){
                filenumber=atol(argv[7]);
        }
        gentables();
        again:
        fprintf(stderr,"\nFile %i\n",filenumber);
        if (read_header()){
                for (a=0;a<filenumber;a++)
                        make_page(a);
		make_index();
                return 0;
        }
        lw=(x+15)>>4;
        lb=(x+7)>>3;
        ox=x/17;
        oy=y/15;
        fprintf(stderr,"Input: %i*%i pixels, %f*%f dpi, %.1fMB.\n",x,y,dpi*17,dpi*15,(float)lb*y/1048576);
        fprintf(stderr,"Ouput: %i*%i pixels, %f*%f dpi, %.1fKB raw data.\n",ox,oy,dpi,dpi,(float)ox*oy/1024);
        l1=(unsigned char*)malloc(lw*2);
        l2=(unsigned long*)malloc(lw*sizeof(unsigned long));
        l4=(unsigned long long*)malloc(lw*sizeof(unsigned long long));
        sprintf(string,"%s%d.png",basename_,filenumber);
        filenumber++;
        of=fopen(string,"w");
        open_png();
        for (z=oy;z;z--){
                if (!(z&15)){
                        fprintf(stderr,".");
                        fflush(stderr);
                } 
                load_to_4();
                export_from_4();
        }
        close_png();
        fprintf(stderr,"\nWritten %lu bytes of data, ratio %.1f%%\n",ftell(of),(float)ftell(of)*100/ox/oy);
        fclose(of);
        for (a=y%15;a;a--)
                load();
        free(l1);
        free(l2);
        free(l4);
        goto again;
}
コード例 #22
0
ファイル: wtest.c プロジェクト: softirq/libmm
int main(int argc, char **argv)
{
    int i, num, ret;
    long ltime;
    ENTRY e;
    printf("Make one index files\n");
    make_index("test1.idx",&name1, 0);
    printf("Indexing 100 items in two index files:\n");

    /* note the time to index */
    time(&ltime);
    printf("%s",ctime(&ltime));

    /* add 100 keys to each index file */
    for (i = MIN_TEST_START; i < MAX_TEST_END; i++)
    {
        memset(&e, '\0', sizeof(ENTRY));
        e.recptr = i;
        sprintf(e.key, "%2d",i);
        if((ret = add_key(&e, &name1)) == IX_OK)
            printf("add key %s ok.\n", e.key);
        else if(ret = IX_EXISTED)
            printf("add key %s is existed.\n", e.key);
        else
            printf("add key %s error .\n", e.key);
    }
    printf("In Process: ADD %d key ok.\n", MAX_TEST_END);

    printf("Indexing is complete\n\n");
    printf("List the keys in each index file in ascending order:\n\n");
    uplist(&name1);

    /*[>list both files in decending order<]*/
    printf("List the keys for each index file in decending order\n\n");
    downlist(&name1);

    /* add key*/
    for(i = MIN_TEST_START; i < MAX_TEST_END/2; ++i)
    {
        memset(&e, '\0', sizeof(ENTRY));
        num = rand_num();
        e.recptr = num;
        sprintf(e.key, "%2d",num);
        if((ret = add_key(&e, &name1)) == IX_OK)
            printf("add key %s ok.\n", e.key);
        else if(ret = IX_EXISTED)
            printf("add key %s is existed.\n", e.key);
        else
            printf("add key %s error.\n", e.key);
    }

    /* delete some keys and list again */
    printf("\nNow delete half keys in each file\n\n");
    for (i = MIN_TEST_START; i < MAX_TEST_END/2 ; i++)
    {
        /*memset(&e, '\0', sizeof(ENTRY));*/
        num = rand_num();
        e.recptr = num;
        sprintf(e.key, "%2d",num);
            
        if((ret = delete_key(&e, &name1)) == IX_OK)
            printf("delete key %s ok.\n",e.key);
        else if(ret == IX_NOTEXISTED)
            printf("delete key %s not existed.\n",e.key);
        else
            printf("delete key %s error.\n", e.key);

    }

    printf("List the keys now for each index file in ascending order:\n\n");
    uplist(&name1);
    printf("List the keys now for each index file in ascending order:\n\n");
    downlist(&name1);

    printf("exception test.\n");
    printf("------------------------------------------------------------\n");
    for (i = MIN_TEST_START; i < MAX_TEST_END/2 ; i++)
    {
        /*memset(&e, '\0', sizeof(ENTRY));*/
        num = rand_num();
        e.recptr = num;
        sprintf(e.key, "%2d",num);
        if(num %2 == 0)
        {
            if((ret = delete_key(&e, &name1)) == IX_OK)
                printf("delete key %s ok.\n",e.key);
            else if(ret == IX_NOTEXISTED)
                printf("delete key %s not existed.\n",e.key);
            else
                printf("delete key %s error.\n", e.key);
        }
        else
        {
            if((ret = add_key(&e, &name1)) == IX_OK)
                printf("add key %s ok.\n", e.key);
            else if(ret = IX_EXISTED)
                printf("add key %s is existed.\n", e.key);
            else
                printf("add key %s error .\n", e.key);
        }
        if(num %17 == 0)
        {
            printf("exception break.\n");
            break;
        }
    }

    printf("List the keys now for each index file in ascending order:\n\n");
    uplist(&name1);
    printf("List the keys now for each index file in ascending order:\n\n");
    downlist(&name1);

    /* always close all files */
    close_index(&name1);
}