diff options
author | Arnur Nigmetov <a.nigmetov@gmail.com> | 2016-09-05 13:32:05 +0200 |
---|---|---|
committer | Arnur Nigmetov <a.nigmetov@gmail.com> | 2016-09-05 13:32:05 +0200 |
commit | 7b850b8ee43fb7f8a0b2a1565ed01102d40b0a14 (patch) | |
tree | 171852c6acd2c8be4390c53a52debf70ca4930b3 /geom_bottleneck/bottleneck/include | |
parent | d1cf630f193cff61c83999600550634032ed1739 (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/include')
-rw-r--r-- | geom_bottleneck/bottleneck/include/ANN/ANN.h | 13 | ||||
-rw-r--r-- | geom_bottleneck/bottleneck/include/ANN/bd_tree.h | 3 | ||||
-rw-r--r-- | geom_bottleneck/bottleneck/include/ANN/kd_tree.h | 7 | ||||
-rw-r--r-- | geom_bottleneck/bottleneck/include/basic_defs_bt.h | 12 | ||||
-rw-r--r-- | geom_bottleneck/bottleneck/include/bottleneck.h | 2 | ||||
-rw-r--r-- | geom_bottleneck/bottleneck/include/def_debug_bt.h | 8 |
6 files changed, 40 insertions, 5 deletions
diff --git a/geom_bottleneck/bottleneck/include/ANN/ANN.h b/geom_bottleneck/bottleneck/include/ANN/ANN.h index cd48d8e..004dfe2 100644 --- a/geom_bottleneck/bottleneck/include/ANN/ANN.h +++ b/geom_bottleneck/bottleneck/include/ANN/ANN.h @@ -96,7 +96,6 @@ #include <cstdlib> // standard lib includes #include <cmath> // math includes -#include <iostream> // I/O streams #include <cstring> // C-style strings #include <vector> #include <assert.h> @@ -130,6 +129,12 @@ #define ANNcopyright "David M. Mount and Sunil Arya" #define ANNlatestRev "Jan 27, 2010" +#include "def_debug_bt.h" + +#ifndef FOR_R_TDA +#include <iostream> // I/O streams +#endif + namespace geom_bt { //---------------------------------------------------------------------- // ANNbool @@ -798,8 +803,10 @@ public: int bs = 1, // bucket size ANNsplitRule split = ANN_KD_SUGGEST); // splitting method +#ifndef FOR_R_TDA ANNkd_tree( // build from dump file std::istream& in); // input stream for dump file +#endif ~ANNkd_tree(); // tree destructor @@ -834,6 +841,7 @@ public: ANNpointArray thePoints() // return pointer to points { return pts; } +#ifndef FOR_R_TDA virtual void Print( // print the tree (for debugging) ANNbool with_pts, // print points as well? std::ostream& out); // output stream @@ -841,6 +849,7 @@ public: virtual void Dump( // dump entire tree ANNbool with_pts, // print points as well? std::ostream& out); // output stream +#endif virtual void getStats( // compute tree statistics ANNkdStats& st); // the statistics (modified) @@ -885,8 +894,10 @@ public: ANNsplitRule split = ANN_KD_SUGGEST, // splitting rule ANNshrinkRule shrink = ANN_BD_SUGGEST); // shrinking rule +#ifndef FOR_R_TDA ANNbd_tree( // build from dump file std::istream& in); // input stream for dump file +#endif }; //---------------------------------------------------------------------- diff --git a/geom_bottleneck/bottleneck/include/ANN/bd_tree.h b/geom_bottleneck/bottleneck/include/ANN/bd_tree.h index 0791429..38cecb7 100644 --- a/geom_bottleneck/bottleneck/include/ANN/bd_tree.h +++ b/geom_bottleneck/bottleneck/include/ANN/bd_tree.h @@ -29,6 +29,7 @@ #include <ANN/ANNx.h> // all ANN includes #include "kd_tree.h" // kd-tree includes +#include "def_debug_bt.h" namespace geom_bt { //---------------------------------------------------------------------- @@ -91,7 +92,9 @@ public: ANNkdStats &st, // statistics ANNorthRect &bnd_box); // bounding box virtual void print(int level, ostream &out);// print node +#ifndef FOR_R_TDA virtual void dump(ostream &out); // dump node +#endif virtual void ann_search(ANNdist); // standard search virtual void ann_pri_search(ANNdist); // priority search diff --git a/geom_bottleneck/bottleneck/include/ANN/kd_tree.h b/geom_bottleneck/bottleneck/include/ANN/kd_tree.h index 5fb362d..a1e53e5 100644 --- a/geom_bottleneck/bottleneck/include/ANN/kd_tree.h +++ b/geom_bottleneck/bottleneck/include/ANN/kd_tree.h @@ -31,6 +31,7 @@ #include <utility> // for std::pair #include <ANN/ANNx.h> // all ANN includes +#include "def_debug_bt.h" using namespace std; // make std:: available @@ -73,7 +74,9 @@ public: ANNorthRect &bnd_box) = 0; // bounding box // print node virtual void print(int level, ostream &out) = 0; +#ifndef FOR_R_TDA virtual void dump(ostream &out) = 0; // dump node +#endif friend class ANNkd_tree; // allow kd-tree to access us @@ -139,7 +142,9 @@ public: ANNkdStats &st, // statistics ANNorthRect &bnd_box); // bounding box virtual void print(int level, ostream &out);// print node +#ifndef FOR_R_TDA virtual void dump(ostream &out); // dump node +#endif virtual void ann_search(ANNdist); // standard search virtual void ann_pri_search(ANNdist); // priority search @@ -217,7 +222,9 @@ public: ANNkdStats &st, // statistics ANNorthRect &bnd_box); // bounding box virtual void print(int level, ostream &out);// print node +#ifndef FOR_R_TDA virtual void dump(ostream &out); // dump node +#endif virtual void ann_search(ANNdist); // standard search virtual void ann_pri_search(ANNdist); // priority search diff --git a/geom_bottleneck/bottleneck/include/basic_defs_bt.h b/geom_bottleneck/bottleneck/include/basic_defs_bt.h index 5334b6d..759f18e 100644 --- a/geom_bottleneck/bottleneck/include/basic_defs_bt.h +++ b/geom_bottleneck/bottleneck/include/basic_defs_bt.h @@ -27,16 +27,20 @@ #endif #include <vector> +#include <stdexcept> #include <math.h> #include <cstddef> #include <unordered_map> #include <unordered_set> -#include <iostream> #include <string> #include <assert.h> #include "def_debug_bt.h" +#ifndef FOR_R_TDA +#include <iostream> +#endif + namespace geom_bt { @@ -50,7 +54,9 @@ struct Point { bool operator!=(const Point& other) const; Point(CoordinateType ax, CoordinateType ay) : x(ax), y(ay) {} Point() : x(0.0), y(0.0) {} +#ifndef FOR_R_TDA friend std::ostream& operator<<(std::ostream& output, const Point p); +#endif }; struct DiagramPoint @@ -90,7 +96,9 @@ public: //return 0.5 * ( x + y); } +#ifndef FOR_R_TDA friend std::ostream& operator<<(std::ostream& output, const DiagramPoint p); +#endif }; struct PointHash { @@ -130,7 +138,9 @@ public: std::unordered_set<DiagramPoint, DiagramPointHash>::iterator end() { return points.end(); } std::unordered_set<DiagramPoint, DiagramPointHash>::const_iterator cbegin() const { return points.cbegin(); } std::unordered_set<DiagramPoint, DiagramPointHash>::const_iterator cend() const { return points.cend(); } +#ifndef FOR_R_TDA friend std::ostream& operator<<(std::ostream& output, const DiagramPointSet& ps); +#endif friend void addProjections(DiagramPointSet& A, DiagramPointSet& B); template<class PairIterator> DiagramPointSet(PairIterator first, PairIterator last); template<class PairIterator> void fillIn(PairIterator first, PairIterator last); diff --git a/geom_bottleneck/bottleneck/include/bottleneck.h b/geom_bottleneck/bottleneck/include/bottleneck.h index 19ae89a..3267c5d 100644 --- a/geom_bottleneck/bottleneck/include/bottleneck.h +++ b/geom_bottleneck/bottleneck/include/bottleneck.h @@ -22,7 +22,7 @@ #define BOTTLENECK_H -#include <iostream> +//#include <iostream> #include <fstream> #include <vector> #include <algorithm> diff --git a/geom_bottleneck/bottleneck/include/def_debug_bt.h b/geom_bottleneck/bottleneck/include/def_debug_bt.h index eaf356d..60f834e 100644 --- a/geom_bottleneck/bottleneck/include/def_debug_bt.h +++ b/geom_bottleneck/bottleneck/include/def_debug_bt.h @@ -18,12 +18,16 @@ */ -#ifndef DEF_DEBUG_H -#define DEF_DEBUG_H +#ifndef DEF_DEBUG_BT_H +#define DEF_DEBUG_BT_H //#define DEBUG_BOUND_MATCH //#define DEBUG_NEIGHBOUR_ORACLE //#define DEBUG_MATCHING //#define DEBUG_AUCTION +// This symbol should be defined only in the version +// for R package TDA, to comply with some CRAN rules +// like no usage of cout, cerr, cin, exit, etc. +//#define FOR_R_TDA #endif |