summaryrefslogtreecommitdiff
path: root/geom_bottleneck/bottleneck/src/ann/ANN.cpp
diff options
context:
space:
mode:
authorArnur Nigmetov <a.nigmetov@gmail.com>2016-09-05 13:32:05 +0200
committerArnur Nigmetov <a.nigmetov@gmail.com>2016-09-05 13:32:05 +0200
commit7b850b8ee43fb7f8a0b2a1565ed01102d40b0a14 (patch)
tree171852c6acd2c8be4390c53a52debf70ca4930b3 /geom_bottleneck/bottleneck/src/ann/ANN.cpp
parentd1cf630f193cff61c83999600550634032ed1739 (diff)
Technical changes for R integration
Avoid including iostream (R complains about that). All output protected by preprocessor directive (R checker should not see an instance of std::cout << in your code). Also added getWassersteinCost to be in line with the Dionysus implementation used in TDA.
Diffstat (limited to 'geom_bottleneck/bottleneck/src/ann/ANN.cpp')
-rw-r--r--geom_bottleneck/bottleneck/src/ann/ANN.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/geom_bottleneck/bottleneck/src/ann/ANN.cpp b/geom_bottleneck/bottleneck/src/ann/ANN.cpp
index 7bae577..83c7ef6 100644
--- a/geom_bottleneck/bottleneck/src/ann/ANN.cpp
+++ b/geom_bottleneck/bottleneck/src/ann/ANN.cpp
@@ -30,9 +30,11 @@
#include <ciso646> // make VS more conformal
#endif
+#include <stdexcept>
#include <cstdlib> // C standard lib defs
#include <ANN/ANNx.h> // all ANN includes
#include <ANN/ANNperf.h> // ANN performance
+#include "def_debug_bt.h"
@@ -80,10 +82,12 @@ void annPrintPt( // print a point
int dim, // the dimension
std::ostream &out) // output stream
{
+#ifndef FOR_R_TDA
for (int j = 0; j < dim; j++) {
out << pt[j];
if (j < dim-1) out << " ";
}
+#endif
}
//----------------------------------------------------------------------
@@ -197,11 +201,16 @@ bool ANNorthRect::intersects(const int dim, const ANNorthRect& r) const
void annError(const char* msg, ANNerr level)
{
if (level == ANNabort) {
+#ifndef FOR_R_TDA
cerr << "ANN: ERROR------->" << msg << "<-------------ERROR\n";
- exit(1);
+#endif
+ throw std::runtime_error(std::string("ANN: Error: ") + std::string(msg));
+ //exit(1);
}
else {
+#ifndef FOR_R_TDA
cerr << "ANN: WARNING----->" << msg << "<-------------WARNING\n";
+#endif
}
}