... | ... |
@@ -42,15 +42,9 @@ void AmplitudeGibbsSampler::sync(PatternGibbsSampler &sampler) |
42 | 42 |
|
43 | 43 |
void AmplitudeGibbsSampler::updateAPMatrix(unsigned row, unsigned col, float delta) |
44 | 44 |
{ |
45 |
- //Rprintf("ap_update - %d %d %.12f\n", row, col, delta); |
|
46 |
- //Rprintf("ap_update - %d %d %x\n", row, col, *((uint32_t*)(&delta))); |
|
47 | 45 |
for (unsigned j = 0; j < mAPMatrix.nCol(); ++j) |
48 | 46 |
{ |
49 |
- float temp = (*mOtherMatrix)(col,j); |
|
50 |
- //Rprintf("P[j] - %x\n", *((uint32_t*)(&temp))); |
|
51 | 47 |
mAPMatrix(row,j) += delta * (*mOtherMatrix)(col,j); |
52 |
- //float temp = mAPMatrix(row,j); |
|
53 |
- //Rprintf("ap_update_fin - %x\n", *((uint32_t*)(&temp))); |
|
54 | 48 |
} |
55 | 49 |
} |
56 | 50 |
|
... | ... |
@@ -141,14 +135,9 @@ void PatternGibbsSampler::sync(AmplitudeGibbsSampler &sampler) |
141 | 135 |
|
142 | 136 |
void PatternGibbsSampler::updateAPMatrix(unsigned row, unsigned col, float delta) |
143 | 137 |
{ |
144 |
- //Rprintf("ap_update - %d %d %x\n", row, col, *((uint32_t*)(&delta))); |
|
145 | 138 |
for (unsigned i = 0; i < mAPMatrix.nRow(); ++i) |
146 | 139 |
{ |
147 |
- float temp = (*mOtherMatrix)(i,row); |
|
148 |
- //Rprintf("A[i] - %x\n", *((uint32_t*)(&temp))); |
|
149 | 140 |
mAPMatrix(i,col) += delta * (*mOtherMatrix)(i,row); |
150 |
- //float temp = mAPMatrix(i,col); |
|
151 |
- //Rprintf("ap_update_fin - %x\n", *((uint32_t*)(&temp))); |
|
152 | 141 |
} |
153 | 142 |
} |
154 | 143 |
|
... | ... |
@@ -3,9 +3,9 @@ |
3 | 3 |
|
4 | 4 |
#include "GapsAssert.h" |
5 | 5 |
#include "Archive.h" |
6 |
-#include "Matrix.h" |
|
7 |
-#include "Random.h" |
|
8 |
-#include "Algorithms.h" |
|
6 |
+#include "math/Matrix.h" |
|
7 |
+#include "math/Random.h" |
|
8 |
+#include "math/Algorithms.h" |
|
9 | 9 |
#include "ProposalQueue.h" |
10 | 10 |
#include "AtomicDomain.h" |
11 | 11 |
|
... | ... |
@@ -230,7 +230,6 @@ unsigned col) |
230 | 230 |
: temp; |
231 | 231 |
if (mass >= gaps::algo::epsilon) |
232 | 232 |
{ |
233 |
- //Rprintf("B - %x\n", *((uint32_t*)&mass)); |
|
234 | 233 |
addMass(pos, mass, row, col); |
235 | 234 |
} |
236 | 235 |
} |
... | ... |
@@ -247,7 +246,6 @@ unsigned col) |
247 | 246 |
float deltaLL = impl()->computeDeltaLL(row, col, mass); |
248 | 247 |
if (deltaLL * mAnnealingTemp >= std::log(gaps::random::uniform())) |
249 | 248 |
{ |
250 |
- //Rprintf("D - %x\n", *((uint32_t*)&mass)); |
|
251 | 249 |
addMass(pos, mass, row, col); |
252 | 250 |
} |
253 | 251 |
} |
... | ... |
@@ -262,8 +260,6 @@ unsigned r1, unsigned c1, unsigned r2, unsigned c2) |
262 | 260 |
float deltaLL = impl()->computeDeltaLL(r1, c1, -mass, r2, c2, mass); |
263 | 261 |
if (deltaLL * mAnnealingTemp > std::log(gaps::random::uniform())) |
264 | 262 |
{ |
265 |
- float temp = -mass; |
|
266 |
- //Rprintf("%x %x\n", *((uint32_t*)(&temp)), *((uint32_t*)(&mass))); |
|
267 | 263 |
removeMass(src, mass, r1, c1); |
268 | 264 |
addMass(dest, mass, r2, c2); |
269 | 265 |
} |
... | ... |
@@ -368,7 +364,6 @@ template <class T, class MatA, class MatB> |
368 | 364 |
float GibbsSampler<T, MatA, MatB>::gibbsMass(unsigned row, unsigned col, float mass) |
369 | 365 |
{ |
370 | 366 |
AlphaParameters alpha = impl()->alphaParameters(row, col); |
371 |
- //Rprintf("alpha param - %f %f\n", alpha.s, alpha.su); |
|
372 | 367 |
alpha.s *= mAnnealingTemp / 2.0; |
373 | 368 |
alpha.su *= mAnnealingTemp / 2.0; |
374 | 369 |
float mean = (2.0 * alpha.su - mLambda) / (2.0 * alpha.s); |
... | ... |
@@ -402,7 +397,6 @@ float GibbsSampler<T, MatA, MatB>::gibbsMass(unsigned r1, unsigned c1, float m1, |
402 | 397 |
unsigned r2, unsigned c2, float m2) |
403 | 398 |
{ |
404 | 399 |
AlphaParameters alpha = impl()->alphaParameters(r1, c1, r2, c2); |
405 |
- //Rprintf("alpha param - %f %f\n", alpha.s, alpha.su); |
|
406 | 400 |
alpha.s *= mAnnealingTemp; |
407 | 401 |
alpha.su *= mAnnealingTemp; |
408 | 402 |
|
... | ... |
@@ -1,16 +1,15 @@ |
1 |
-PKG_CPPFLAGS = -DGAPS_DEBUG -DBOOST_MATH_PROMOTE_DOUBLE_POLICY=0 |
|
2 |
-PKG_CPPFLAGS = -DBOOST_MATH_PROMOTE_DOUBLE_POLICY=0 |
|
3 |
-OBJECTS = Algorithms.o \ |
|
4 |
- AtomicDomain.o \ |
|
1 |
+PKG_CPPFLAGS = -DBOOST_MATH_PROMOTE_DOUBLE_POLICY=0 |
|
2 |
+OBJECTS = AtomicDomain.o \ |
|
5 | 3 |
Cogaps.o \ |
6 | 4 |
GapsRunner.o \ |
7 | 5 |
GapsStatistics.o \ |
8 | 6 |
GibbsSampler.o \ |
9 |
- Matrix.o \ |
|
10 | 7 |
ProposalQueue.o \ |
11 |
- Random.o \ |
|
12 | 8 |
RcppExports.o \ |
13 | 9 |
test-runner.o \ |
10 |
+ math/Algorithms.o \ |
|
11 |
+ math/Matrix.o \ |
|
12 |
+ math/Random.o \ |
|
14 | 13 |
cpp_tests/testAlgorithms.o \ |
15 | 14 |
cpp_tests/testAtomicDomain.o \ |
16 | 15 |
cpp_tests/testGapsRunner.o \ |
... | ... |
@@ -1,10 +1,10 @@ |
1 | 1 |
#include "catch.h" |
2 | 2 |
#include "../Archive.h" |
3 |
-#include "../Matrix.h" |
|
3 |
+#include "../math/Matrix.h" |
|
4 | 4 |
#include "../AtomicSupport.h" |
5 | 5 |
#include "../GibbsSampler.h" |
6 | 6 |
#include "../InternalState.h" |
7 |
-#include "../Random.h" |
|
7 |
+#include "../math/Random.h" |
|
8 | 8 |
|
9 | 9 |
#if 0 |
10 | 10 |
|
11 | 11 |
similarity index 87% |
12 | 12 |
rename from src/Algorithms.cpp |
13 | 13 |
rename to src/math/Algorithms.cpp |
... | ... |
@@ -98,7 +98,6 @@ bool gaps::algo::isColZero(const ColMatrix &mat, unsigned col) |
98 | 98 |
AlphaParameters gaps::algo::alphaParameters(unsigned size, const float *D, |
99 | 99 |
const float *S, const float *AP, const float *mat) |
100 | 100 |
{ |
101 |
-/* |
|
102 | 101 |
gaps::simd::packedFloat ratio, pMat, pD, pAP, pS; |
103 | 102 |
gaps::simd::packedFloat partialS = 0.f, partialSU = 0.f; |
104 | 103 |
gaps::simd::Index i = 0; |
... | ... |
@@ -120,25 +119,12 @@ const float *S, const float *AP, const float *mat) |
120 | 119 |
su += (fratio * (D[j] - AP[j])) / S[j]; |
121 | 120 |
} |
122 | 121 |
return AlphaParameters(s,su); |
123 |
- float fratio, s = partialS.scalar(), su = partialSU.scalar(); |
|
124 |
- for (unsigned j = i.value(); j < size; ++j) |
|
125 |
-*/ |
|
126 |
- float fratio = 0.f, s = 0.f, su = 0.f; |
|
127 |
- for (unsigned j = 0; j < size; ++j) |
|
128 |
- { |
|
129 |
- fratio = mat[j] / S[j]; |
|
130 |
- s += fratio * fratio; |
|
131 |
- su += fratio * (D[j] - AP[j]) / S[j]; |
|
132 |
- //Rprintf("AP[j] - %x\n", *((uint32_t*)(&AP[j]))); |
|
133 |
- } |
|
134 |
- return AlphaParameters(s,su); |
|
135 | 122 |
} |
136 | 123 |
|
137 | 124 |
// |
138 | 125 |
AlphaParameters gaps::algo::alphaParameters(unsigned size, const float *D, |
139 | 126 |
const float *S, const float *AP, const float *mat1, const float *mat2) |
140 | 127 |
{ |
141 |
-/* |
|
142 | 128 |
gaps::simd::packedFloat ratio, pMat1, pMat2, pD, pAP, pS; |
143 | 129 |
gaps::simd::packedFloat partialS = 0.f, partialSU = 0.f; |
144 | 130 |
gaps::simd::Index i = 0; |
... | ... |
@@ -153,16 +139,13 @@ const float *S, const float *AP, const float *mat1, const float *mat2) |
153 | 139 |
partialS += ratio * ratio; |
154 | 140 |
partialSU += ratio * (pD - pAP) / pS; |
155 | 141 |
} |
142 |
+ |
|
156 | 143 |
float fratio, s = partialS.scalar(), su = partialSU.scalar(); |
157 | 144 |
for (unsigned j = i.value(); j < size; ++j) |
158 |
-*/ |
|
159 |
- float fratio = 0.f, s = 0.f, su = 0.f; |
|
160 |
- for (unsigned j = 0; j < size; ++j) |
|
161 | 145 |
{ |
162 | 146 |
fratio = (mat1[j] - mat2[j]) / S[j]; |
163 | 147 |
s += fratio * fratio; |
164 | 148 |
su += fratio * (D[j] - AP[j]) / S[j]; |
165 |
- //Rprintf("AP[j] - %x\n", *((uint32_t*)(&AP[j]))); |
|
166 | 149 |
} |
167 | 150 |
return AlphaParameters(s,su); |
168 | 151 |
} |
175 | 158 |
similarity index 99% |
176 | 159 |
rename from src/Matrix.h |
177 | 160 |
rename to src/math/Matrix.h |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
#ifndef __COGAPS_MATRIX_H__ |
2 | 2 |
#define __COGAPS_MATRIX_H__ |
3 | 3 |
|
4 |
-#include "Archive.h" |
|
4 |
+#include "../Archive.h" |
|
5 | 5 |
|
6 | 6 |
#include <Rcpp.h> |
7 | 7 |
#include <boost/align/aligned_allocator.hpp> |
8 | 8 |
similarity index 99% |
9 | 9 |
rename from src/Random.cpp |
10 | 10 |
rename to src/math/Random.cpp |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
// [[Rcpp::depends(BH)]] |
2 | 2 |
|
3 | 3 |
#include "Random.h" |
4 |
-#include "GapsAssert.h" |
|
4 |
+#include "../GapsAssert.h" |
|
5 | 5 |
|
6 | 6 |
#include <boost/random/uniform_01.hpp> |
7 | 7 |
#include <boost/random/uniform_real_distribution.hpp> |