summaryrefslogtreecommitdiff
path: root/lib/orthogonal.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-10 12:37:02 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-10 12:37:02 -0400
commite53a4c09eb78e4c5a8365f1328a69ba7f9ff8992 (patch)
tree3c252af9ffafacab8392bf864270dcd034ed07ed /lib/orthogonal.c
parent609fb52b670d8ed74584a988b8c63da82d8d523b (diff)
parent1810103bc9ac4c9a8d432d113f5ca6eae6560fb4 (diff)
downloadc++-e53a4c09eb78e4c5a8365f1328a69ba7f9ff8992.tar.gz
c++-e53a4c09eb78e4c5a8365f1328a69ba7f9ff8992.tar.bz2
c++-e53a4c09eb78e4c5a8365f1328a69ba7f9ff8992.zip
Merge branch 'master' of m5:/srv/git/wolff
Diffstat (limited to 'lib/orthogonal.c')
-rw-r--r--lib/orthogonal.c99
1 files changed, 0 insertions, 99 deletions
diff --git a/lib/orthogonal.c b/lib/orthogonal.c
deleted file mode 100644
index 87569ae..0000000
--- a/lib/orthogonal.c
+++ /dev/null
@@ -1,99 +0,0 @@
-
-#include "orthogonal.h"
-
-void vector_replace(q_t n, double *v1, const double *v2) {
- // writes vector v2 of length n to memory located at v1
- for (q_t i = 0; i < n; i++) {
- v1[i] = v2[i];
- }
-}
-
-void vector_add(q_t n, double *v1, const double *v2) {
- // adds vector v2 of length n to vector v1
- for (q_t i = 0; i < n; i++) {
- v1[i] += v2[i];
- }
-}
-
-void vector_subtract(q_t n, double *v1, const double *v2) {
- // subtracts vector v2 of length n from vector v1
- for (q_t i = 0; i < n; i++) {
- v1[i] -= v2[i];
- }
-}
-
-double *vector_rotate(q_t n, const double *rot, const double *vec) {
- // multiplies n by n rotation matrix rot to vector vec
- double *rot_vec = (double *)malloc(n * sizeof(double));
-
- double prod = 0.0;
- for (q_t i = 0; i < n; i++) {
- prod += rot[i] * vec[i];
- }
-
- for (q_t i = 0; i < n; i++) {
- rot_vec[i] = vec[i] - 2 * prod * rot[i];
- }
-
- return rot_vec;
-}
-
-double *vector_rotate_inverse(q_t n, const double *rot, const double *vec) {
- double *rot_vec = (double *)calloc(n, sizeof(double));
-
- for (q_t i = 0; i < n; i++) {
- for (q_t j = 0; j < n; j++) {
- rot_vec[i] += rot[n * j + i] * vec[j];
- }
- }
-
- return rot_vec;
-}
-
-double vector_dot(q_t n, const double *v1, const double *v2) {
- double dot = 0;
-
- for (q_t i = 0; i < n; i++) {
- dot += v1[i] * v2[i];
- }
-
- return dot;
-}
-
-double *orthogonal_rotate(q_t n, const double *r, const double *m) {
- double *mul = (double *)calloc(n * n, sizeof(double));
-
- for (q_t i = 0; i < n; i++) {
- double akOki = 0;
-
- for (q_t k = 0; k < n; k++) {
- akOki += r[k] * m[n * k + i];
- }
-
- for (q_t j = 0; j < n; j++) {
- mul[n * j + i] = m[n * j + i] - 2 * akOki * r[j];
- }
- }
-
- return mul;
-}
-
-double *gen_rot(gsl_rng *r, q_t n) {
- double *v = (double *)malloc(n * sizeof(double));
-
- double v2 = 0;
-
- for (q_t i = 0; i < n; i++) {
- v[i] = gsl_ran_ugaussian(r);
- v2 += v[i] * v[i];
- }
-
- double magv = sqrt(v2);
-
- for (q_t i = 0; i < n; i++) {
- v[i] /= magv;
- }
-
- return v;
-}
-