Пример #1
0
/*  FUNCTION:  Calculate a grid of Voigt profiles.                          */
int
calcprofiles(struct transit *tr){
  struct transithint *th = tr->ds.th; /* transithint struct                 */
  struct opacity *op=tr->ds.op;     /* Opacity struct                       */
  int i, j;                         /* for-loop indices                     */
  int nDop, nLor;                   /* Number of Doppler and Lorentz-widths */
  double Lmin, Lmax, Dmin, Dmax;    /* Minimum and maximum widths           */
  PREC_VOIGT ***profile;            /* Grid of Voigt profiles               */
  float timesalpha=tr->timesalpha;  /* Voigt wings width                    */
  struct timeval tv;  /* Time-keeping variables                             */
  double t0=0.0;

  /* Make logscale grid for the profile widths:                             */
  /* FINDME: Add check that these numbers make sense                        */
  nDop = op->nDop = th->nDop;
  nLor = op->nLor = th->nLor;
  Dmin = th->dmin;
  Dmax = th->dmax;
  Lmin = th->lmin;
  Lmax = th->lmax;
  op->aDop = logspace(Dmin, Dmax, nDop);
  op->aLor = logspace(Lmin, Lmax, nLor);

  /* Allocate array for the profile half-size:                              */
  op->profsize    = (PREC_NREC **)calloc(nDop,      sizeof(PREC_NREC *));
  op->profsize[0] = (PREC_NREC  *)calloc(nDop*nLor, sizeof(PREC_NREC));
  for (i=1; i<nDop; i++)
    op->profsize[i] = op->profsize[0] + i*nLor;

  /* Allocate grid of Voigt profiles:                                       */
  op->profile    = (PREC_VOIGT ***)calloc(nDop,      sizeof(PREC_VOIGT **));
  op->profile[0] = (PREC_VOIGT  **)calloc(nDop*nLor, sizeof(PREC_VOIGT *));
  for (i=1; i<nDop; i++){
    op->profile[i] = op->profile[0] + i*nLor;
  }
  profile = op->profile;
  tr_output(TOUT_RESULT, "Number of Voigt profiles: %d.\n", nDop*nLor);

  t0 = timestart(tv, "Begin Voigt profiles calculation.");
  /* Evaluate the profiles for the array of widths:                         */
  for   (i=0; i<nDop; i++){
    for (j=0; j<nLor; j++){
      /* Skip calculation if Doppler width << Lorentz width:                */
      /* Set size and pointer to previous profile:                          */
      if (op->aDop[i]*10.0 < op->aLor[j]  &&  i != 0){
        op->profsize[i][j] = op->profsize[i-1][j];
        profile[i][j] = profile[i-1][j];
      }
      else{ /* Calculate a new profile for given widths:                    */
        op->profsize[i][j] = getprofile(&profile[i][j],
                             tr->wns.d/tr->owns.o, op->aDop[i], op->aLor[j],
                             timesalpha, tr->owns.n);
      }
      tr_output(TOUT_DEBUG, "Profile[%2d][%2d] size = %4li  (D=%.3g, "
        "L=%.3g).\n", i, j, 2*op->profsize[i][j]+1, op->aDop[i], op->aLor[j]);
    }
  }
  t0 = timecheck(verblevel, 0, 0, "End Voigt-profile calculation.", tv, t0);
  return 0;
}
Пример #2
0
void dat_dump(struct index_s *index)
{
    time_info tinfo;
    int time;
    struct datrietree_s* datrie;
    struct stat_info sinfo;

    timestart(&tinfo);
    datrie = loaddatrie_bindict(index->datrie_index_file_name);
    time = timeend(&tinfo);
    printf("Load Datrie Bindict Time: %d\n", time);
    if (!datrie) {
        printf("Load Index Failed: %s\n", index->datrie_index_file_name);
        return;
    }

    printf("Wordimage Size: %lubyte\n", datrie->wordimage->size * sizeof(int));
    printf("Array Size: %lubyte\n", datrie->datrie->size * sizeof(int) * 3);

    stat_count(datrie->datrie, &sinfo);
    printf("Array Total Count: %d Zero Count: %lu Ratio: %.3f%%\n",
           datrie->datrie->size,
           sinfo.zero_count,
           ((double)sinfo.zero_count / (double)datrie->datrie->size)*100);
    printf("Term Total Count: %lu\n",
           sinfo.term_count);
}
Пример #3
0
int program_make(struct program *prog, struct shader **shader, int num)
{
	int i;
	GLchar log[256] = "nil";
	GLsizei len = 0;
	GLint res = GL_FALSE;

	if (!prog) {
		errno = EFAULT;
		return -1;
	}

	timeinit();

	prog->id = glCreateProgram();
	if (prog->id == 0) {
		glerr("glCreateProgram() failed");
		return -1;
	}

	prog->shader = shader;
	prog->shader_num = num;

	for (i = 0; i < num; i++) {
		if (make_shader(shader[i]) < 0) {
			_err("shader %s failed\n", shader[i]->name);
			goto err;
		}
		glAttachShader(prog->id, shader[i]->id);
	}

	timestart();
	glLinkProgram(prog->id);
	glGetProgramiv(prog->id, GL_LINK_STATUS, &res);
	if (res != GL_TRUE) {
		_err("failed to link program\n");
		goto err;
	}

	timestop("program %d linked\n", prog->id);
	return prog->id;

err:
	if (prog->id > 0) {
		glGetProgramInfoLog(prog->id, sizeof (log), &len, log);
		_msg("len: %d, log: %s\n", len, log);
	}

	program_clean(prog);
	return -1;
}
Пример #4
0
void openAll(const char *p)
{
    ScbPath path;
    ScbPageId id;
    ScbPagePtr page;
    strncpy(path.scbname, p, MAX_PATH);
    strncpy(id.id, "10", MAX_PAGEID_LEN);

    // 
    
    timestart();
    ScbDocPtr doc = scb_doc_open(&path);
    ScbPagesPtr pages = scb_doc_get_pages(doc);
    page = scb_pages_get_page(pages, &id);
    timeend();
    

}
Пример #5
0
void openDirectly(const char *p)
{
    // open directly with p1
    ScbPath path;
    ScbPageId id;
    ScbPagePtr page;
    strncpy(path.scbname, p, MAX_PATH);
    strncpy(id.id, "10", MAX_PAGEID_LEN);
    
    // 
    timestart();
    //page = scb_doc_open_page_directly(&path, &id);
    timeend();

  

    TRACE("done!!!!");
}
Пример #6
0
static int make_shader(struct shader *shader)
{
	GLint res = GL_FALSE;
	GLsizei len = 0;
	GLchar log[4096] = "nil";/* FIXME: some drivers return wrong values for
				 * GL_INFO_LOG_LENGTH use a fixed size instead
				 */
	timeinit();

	if (!shader) {
		errno = EFAULT;
		return -1;
	}

	timestart();

	shader->id = glCreateShader(shader->type);
	if (shader->id == 0) {
		glerr("glCreateShader(%s) failed", shader->name);
		goto error;
	}

	glShaderSource(shader->id, 1, &shader->code, NULL);
	glCompileShader(shader->id);
	glGetShaderiv(shader->id, GL_COMPILE_STATUS, &res);
	if (res != GL_TRUE) {
		glerr("glCompileShader(%s) failed", shader->name);
		goto error;
	}

	timestop("compiled shader %s, id %d type 0x%04x\n", shader->name,
		 shader->id, shader->type);
	return 0;

error:
	if (shader->id > 0) {
		glGetShaderInfoLog(shader->id, sizeof(log), &len, log);
		_msg("len: %d, log: %s\n", len, log);
		glDeleteShader(shader->id);
		shader->id = 0;
	}
	return -1;
}
Пример #7
0
int main()
{
  int *a = NULL;
  int *b = NULL;
  time_info ti1;
  time_info ti2;
  int c = 0;
  char* datafile = "./data";
  sort_data* sd = NULL;
  int max;
  int count;
  
  sd = load_sort_data(datafile);
  count = count_sort_data(sd);
  max = max_sort_data(sd);

  printf("sort data count: %d\n", count);
  printf("sort data max: %d\n", max);
  max++;
  
  a = data_sort_data(sd);
  b = (int*)malloc(sizeof(int) * count);
  
  printf("sort data:\n");
  //  outArray(a, count);
  printf("\n\n");

  printf("counting sort ...\n");
  timestart(&ti1);
  Counting_Sort(a, b, count, max);
  c = timeend(&ti1);
  printf("time:%d\n", c);
  //  outArray(b, count);
  printf("\n\n");

  printf("place sort ...\n");
  timestart(&ti2);
  place_sort(a, b, count, max);
  c = timeend(&ti2);

  printf("time:%d\n", c);
  // outArray(b, count);
  //tofile_sort_data(b, count, "place_sort_data");
  printf("\n");

  printf("bit sort ...\n");
  timestart(&ti2);
  bit_sort(a, b, count, max);
  c = timeend(&ti2);

  printf("time:%d\n", c);
  // outArray(b, count);
  //tofile_sort_data(b, count, "bin_sort_data");
  printf("\n");


  printf("quick sort ...\n");
  timestart(&ti2);
  quick_sort(a, 0, count-1);
  c = timeend(&ti2);

  printf("time:%d\n", c);
  // outArray(b, count);
  //tofile_sort_data(a, count, "quick_sort_data");
  printf("\n");

  unload_sort_data(sd);

  // heap sort
  sd = load_sort_data(datafile);
  count = count_sort_data(sd);
  max = max_sort_data(sd);
  max++;
  
  a = data_sort_data(sd);

  printf("heap sort ...\n");
  timestart(&ti2);
  heap_sort(a, count-1);
  c = timeend(&ti2);

  printf("time:%d\n", c);
  //outArray(b, count);
  tofile_sort_data(a, count, "heap_sort_data");
  printf("\n");

  unload_sort_data(sd);

  // max heap sort
  sd = load_sort_data(datafile);
  count = count_sort_data(sd);
  max = max_sort_data(sd);
  max++;
  
  a = data_sort_data(sd);

  printf("max heap sort ...\n");
  timestart(&ti2);
  max_heap_sort(a, count);
  c = timeend(&ti2);
  printf("time:%d\n", c);
  timestart(&ti2);
  push_heap(a, 2345234);
  push_heap(a, 2344);
  push_heap(a, 1232344);
  push_heap(a, 25234);
  push_heap(a, 235234);
  push_heap(a, 23445234);
  push_heap(a, 65434234);
  push_heap(a, 12323434);
  push_heap(a, 25234);
  push_heap(a, 235234);
  c = timeend(&ti2);
  printf("insert 10 to max heap time:%d\n", c);
  //outArray(b, count);
  tofile_sort_data(a, count, "max_heap_sort_data");
  printf("\n");

  unload_sort_data(sd);

  // insert sort
  sd = load_sort_data(datafile);
  count = count_sort_data(sd);
  max = max_sort_data(sd);
  max++;
  
  a = data_sort_data(sd);

  printf("insert sort ...\n");
  timestart(&ti2);
  insert_sort(a, count-1);
  c = timeend(&ti2);

  printf("time:%d\n", c);
  //outArray(b, count);
  tofile_sort_data(a, count, "insert_sort_data");
  printf("\n");

  unload_sort_data(sd);


  return 0;
}
Пример #8
0
void restart_timeinfo(time_info* ti)
{
  reset_timeinfo(ti);
  timestart(ti);
}