Exemple #1
0
// New station list from a glob structure
stations *newStationList(glob_t *glb)
{
	stations *ss;
	int j, file;

	ss = malloc(sizeof(stations));
	ss->n = 0;
	ss->slist = NULL;

	/* Prepare stations table */
	for (j = 0; j < glb->gl_pathc; j++) {
		glob_t *glbs = filelist(glb->gl_pathv[j], "*Z.SAC");

		for (file = 0; file < glbs->gl_pathc; file++) {
			station *s = loadStation(glbs->gl_pathv[file]);
			int Id = getStationId(ss, s->name, s->net);
			if (Id == -1) {
				addss(ss, s);
			} else {
				killStation(s);
			}
		}
		glbs = killGlob(glbs);
	}

	qsort(&ss->slist[0], ss->n, sizeof(ss->slist[0]), cmpstation);
	return ss;
}
Exemple #2
0
// Load a station file as used by the tomography code
stations *readStationList(char *filename)
{
	stations *ss;
	int j;
	FILE *in;

	float lon, lat, alt;
	char name[200], net[200];

	ss = malloc(sizeof(stations));
	ss->n = 0;
	ss->slist = NULL;

	in = fopen(filename, "r");
	if (in == NULL)
		return ss;

	j = fscanf(in, "%f\t%f\t%f\t%s\t%s", &lon, &lat, &alt, name, net);
	while (j == 5) {
		station *s = newStation(lon, lat, alt, name, net);
		if (s == NULL)
			return NULL;
		addss(ss, s);

		j = fscanf(in, "%f\t%f\t%f\t%s\t%s", &lon, &lat, &alt, name, net);
	}

	fclose(in);
	return ss;
}
float TfirFilter::vec_inner_prod_sse(const float *eax, const float *edi, int ecx)
{
  __m128 xmm3,xmm4,xmm0,xmm1,xmm5,xmm6;
  xorps (xmm3, xmm3);
  xorps (xmm4, xmm4);

  ecx-=8;// sub $8, %%ecx
  if (ecx<0) goto //jb
   mul8_skip;

mul8_loop:
  movups (xmm0,eax);
  movups (xmm1,edi);
  movups (xmm5,16/sizeof(float)+eax);
  movups (xmm6,16/sizeof(float)+edi);
  eax+=32/sizeof(float);
  edi+=32/sizeof(float);
  mulps (xmm1,xmm0);
  mulps (xmm6,xmm5);
  addps (xmm3,xmm1);
  addps (xmm4,xmm6);

  ecx-=8;
  if (ecx>=0) //jae
   goto mul8_loop;

mul8_skip:

  addps (xmm3,xmm4);

  ecx+=4;
  if (ecx<0) //jl
   goto mul4_skip;

  movups (xmm0,eax);
  movups (xmm1,edi);
  eax+=16/sizeof(float);
  edi+=16/sizeof(float);
  mulps (xmm1, xmm0);
  addps (xmm3, xmm1);

  ecx-=4;

mul4_skip:

  ecx+=4;

  goto cond1;

mul1_loop:
  movss (xmm0,eax);
  movss (xmm1,edi);
  eax+=4/sizeof(float);
  edi+=4/sizeof(float);
  mulss (xmm1,xmm0);
  addss (xmm3,xmm1);

cond1:
  ecx-=1;
  if (ecx>=0) // jae
   goto mul1_loop;

  movhlps  (xmm4,xmm3);
  addps    (xmm3,xmm4);
  movaps   (xmm4,xmm3);
  //FIXME: which one?
  xmm4=_mm_shuffle_ps(xmm4,xmm4,0x55);// shufps $0x55, xmm4, xmm4
                                      // shufps $33, xmm4, xmm4
  addss    (xmm3, xmm4);
  float sum;
  movss    (&sum , xmm3);
  return sum;
}