summaryrefslogtreecommitdiff
path: root/hadamard_mcmc.hpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2020-01-30 13:52:53 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2020-01-30 13:52:53 -0500
commitdbee70fe5eb7abca31c01c046ec2174f2dde7665 (patch)
tree399a363dbb2f29986de64401ee2a7270b0b867be /hadamard_mcmc.hpp
parent76204921e61c9178e800b48a9f5343bd44f6854b (diff)
downloadcode-dbee70fe5eb7abca31c01c046ec2174f2dde7665.tar.gz
code-dbee70fe5eb7abca31c01c046ec2174f2dde7665.tar.bz2
code-dbee70fe5eb7abca31c01c046ec2174f2dde7665.zip
any orthogonal size that is a multiple of four is now available instead of powers of two
Diffstat (limited to 'hadamard_mcmc.hpp')
-rw-r--r--hadamard_mcmc.hpp26
1 files changed, 4 insertions, 22 deletions
diff --git a/hadamard_mcmc.hpp b/hadamard_mcmc.hpp
index eab9916..bca8ae2 100644
--- a/hadamard_mcmc.hpp
+++ b/hadamard_mcmc.hpp
@@ -18,6 +18,10 @@ public:
}
}
+ Orthogonal(const std::vector<double>& x) : m(x) {
+ d = sqrt(x.size());
+ }
+
unsigned size() const { return d; }
double& operator()(unsigned i, unsigned j) { return m[d * i + j]; }
@@ -37,28 +41,6 @@ public:
}
};
-Orthogonal walsh(unsigned k) {
- if (k == 0) {
- return Orthogonal(1);
- } else {
- Orthogonal s = walsh(k - 1);
- Orthogonal t = Orthogonal(2 * s.size());
-
- for (unsigned i = 0; i < s.size(); i++) {
- for (unsigned j = 0; j < s.size(); j++) {
- double sij = s(i, j);
-
- t(i, j) = sij;
- t(s.size() + i, j) = sij;
- t(i, s.size() + j) = sij;
- t(s.size() + i, s.size() + j) = -sij;
- }
- }
-
- return t;
- }
-}
-
class Givens {
private:
Orthogonal& m;