Commit e940395a authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Use sincos() instead of separate calls to sin() and cos()

parent 120a5b3a
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -635,7 +635,9 @@ void frfme(string data_file, string output_path) {
		  double vkx = vkv[nkv - 1];
		  double vkz = vec_vkzm[jy60];
		  double angle = -vkx * x + vky * y + vkz * z;
		  dcomplex phasf = cos(angle) + uim * sin(angle);
		  double s, c;
		  sincos(angle, &s, &c);
		  dcomplex phasf = c + uim * s;
		  dcomplex term = vec_w[jy60] * phasf * 0.5;
		  double factor = (jy60 == 0 || jy60 == nkv - 1) ? 0.5 : 1.0;
		  term *= factor;
@@ -646,7 +648,9 @@ void frfme(string data_file, string output_path) {
		  double vkx = vkv[nkv - 1];
		  double vkz = vec_vkzm[(nkv - 1) * nkv + jy60];
		  double angle = vkx * x + vky * y + vkz * z;
		  dcomplex phasl = cos(angle) + uim * sin(angle);
		  double s, c;
		  sincos(angle, &s, &c);
		  dcomplex phasl = c + uim * s;
		  dcomplex term = vec_w[(nkv - 1) * nkv + jy60] * phasl * 0.5;
		  double factor = (jy60 == 0 || jy60 == nkv - 1) ? 0.5 : 1.0;
		  term *= factor;
@@ -657,7 +661,9 @@ void frfme(string data_file, string output_path) {
		  double vkx = vkv[jx55];
		  double vkz = vec_vkzm[(jx55) * nkv + jy60];
		  double angle = vkx * x + vky * y + vkz * z;
		  dcomplex phas = cos(angle) + uim * sin(angle);
		  double s, c;
		  sincos(angle, &s, &c);
		  dcomplex phas = c + uim * s;
		  dcomplex term = vec_w[(jx55) * nkv + jy60] * phas;
		  double factor = (jy60 == 0 || jy60 == nkv - 1) ? 0.5 : 1.0;
		  term *= factor;
@@ -799,7 +805,9 @@ void offload_loop(
	  double vkx = vkv[nkvmo];
	  double vkz = vec_vkzm[jy60];
	  double angle = -vkx * x + vky * y + vkz * z;
	  dcomplex phasf = cos(angle) + uim * sin(angle);
	  double s, c;
	  sincos(angle, &s, &c);
	  dcomplex phasf = c + uim * s;
	  dcomplex term = vec_w[jy60] * phasf * 0.5;
	  term *= factor;
	  rsumy += (real(term));
@@ -809,7 +817,9 @@ void offload_loop(
	  double vkx = vkv[nkvmo];
	  double vkz = vec_vkzm[nkvvmo + jy60];
	  double angle = vkx * x + vky * y + vkz * z;
	  dcomplex phasl = cos(angle) + uim * sin(angle);
	  double s, c;
	  sincos(angle, &s, &c);
	  dcomplex phasl = c + uim * s;
	  dcomplex term = vec_w[nkvvmo + jy60] * phasl * 0.5;
	  term *= factor;
	  rsumy += (real(term));
@@ -819,7 +829,9 @@ void offload_loop(
	  double vkx = vkv[jx55];
	  double vkz = vec_vkzm[w_index];
	  double angle = vkx * x + vky * y + vkz * z;
	  dcomplex phas = cos(angle) + uim * sin(angle);
	  double s, c;
	  sincos(angle, &s, &c);
	  dcomplex phas = c + uim * s;
	  dcomplex term = vec_w[w_index] * phas;
	  term *= factor;
	  rsumy += (real(term));