aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-02-27 23:21:36 +0100
committerThomas White <taw@physics.org>2010-02-27 23:21:36 +0100
commitb02fbca84783eebae33a488905e0dcc13839745c (patch)
tree09b3f2913e925cc66b0daa1f921edc32d39c98fc
parent732af8778a49cacbfffe3c451125be84d7f86ee2 (diff)
Doesn't look like native_sin() works out here, sadly...
-rw-r--r--data/diffraction.cl23
1 files changed, 19 insertions, 4 deletions
diff --git a/data/diffraction.cl b/data/diffraction.cl
index a401cdfa..ebacb416 100644
--- a/data/diffraction.cl
+++ b/data/diffraction.cl
@@ -71,9 +71,18 @@ float4 get_q(int x, int y, float cx, float cy, float res, float clen, float k,
}
+float range(float a)
+{
+ a = a >= 0.0 ? a : 2.0*M_PI + a;
+ a = a < 2.0*M_PI ? a : a - 2.0*M_PI;
+
+ return a;
+}
+
+
float lattice_factor(float16 cell, float4 q, int4 ncells)
{
- float f1, f2, f3;
+ float f1, f2, f3, v;
float4 Udotq;
const int na = ncells.s0;
const int nb = ncells.s1;
@@ -84,13 +93,19 @@ float lattice_factor(float16 cell, float4 q, int4 ncells)
Udotq.z = cell.s6*q.x + cell.s7*q.y + cell.s8*q.z;
/* At exact Bragg condition, f1 = na */
- f1 = native_sin(M_PI*(float)na*Udotq.x) / native_sin(M_PI*Udotq.x);
+ v = M_PI*Udotq.x;
+ f1 = sin(v*(float)na) / sin(v);
+ f1 = isnan(f1) ? na : f1;
/* At exact Bragg condition, f2 = nb */
- f2 = native_sin(M_PI*(float)nb*Udotq.y) / native_sin(M_PI*Udotq.y);
+ v = M_PI*Udotq.y;
+ f2 = sin(v*(float)nb) / sin(v);
+ f2 = isnan(f2) ? nb : f2;
/* At exact Bragg condition, f3 = nc */
- f3 = native_sin(M_PI*(float)nc*Udotq.z) / native_sin(M_PI*Udotq.z);
+ v = M_PI*Udotq.z;
+ f3 = sin(v*(float)nc) / sin(v);
+ f3 = isnan(f3) ? nc : f3;
/* At exact Bragg condition, this will multiply the molecular
* part of the structure factor by the number of unit cells,