diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-17 23:27:10 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-17 23:27:10 -0400 |
commit | 722bc71ed8d4e1ae5616c5c8284fbffe21c4ffa4 (patch) | |
tree | af51a79c2b231f699c66fc3dddad343316a919df /lib/orthogonal.h | |
parent | 8a6109a78a6f7b9e9585cd89e8a10d1f626b3af1 (diff) | |
download | c++-722bc71ed8d4e1ae5616c5c8284fbffe21c4ffa4.tar.gz c++-722bc71ed8d4e1ae5616c5c8284fbffe21c4ffa4.tar.bz2 c++-722bc71ed8d4e1ae5616c5c8284fbffe21c4ffa4.zip |
working generator of rotations near the current state
Diffstat (limited to 'lib/orthogonal.h')
-rw-r--r-- | lib/orthogonal.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/orthogonal.h b/lib/orthogonal.h index 6166223..d8ad33d 100644 --- a/lib/orthogonal.h +++ b/lib/orthogonal.h @@ -167,9 +167,9 @@ orthogonal_t <q, double> generate_rotation_uniform (gsl_rng *r, const state_t <o template <q_t q> orthogonal_t <q, double> generate_rotation_perturbation (gsl_rng *r, const state_t <orthogonal_t <q, double>, vector_t <q, double>> *s, double epsilon) { - orthogonal_t <q, double> ptr; + orthogonal_t <q, double> m; vector_t <q, double> tmp_v; - ptr.is_reflection = true; + m.is_reflection = true; tmp_v.x = (double *)malloc(q * sizeof(double)); @@ -196,10 +196,22 @@ orthogonal_t <q, double> generate_rotation_perturbation (gsl_rng *r, const state tmp_v.x[i] /= mag_v; } - vector_t <q, double> v = act(s->R, tmp_v); + vector_t <q, double> v = act_inverse(s->R, tmp_v); free(tmp_v.x); - ptr.x = v.x; + m.x = v.x; - return ptr; + v2 = 0; + + for (q_t i = 0; i < q; i++) { + v2 += m.x[i] * m.x[i]; + } + + mag_v = sqrt(v2); + + for (q_t i = 0; i < q; i++) { + m.x[i] /= mag_v; + } + + return m; } |