summaryrefslogtreecommitdiff
path: root/src/cython/include/Euclidean_strong_witness_complex_interface.h
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-21 13:45:53 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-21 13:45:53 +0000
commit54ed7a649fd461880693f5e9985dc529ae72a39f (patch)
tree2e3bc96b9a6e81711d4a978ecd642d22c51d959b /src/cython/include/Euclidean_strong_witness_complex_interface.h
parent24fafed684bfb8cc4b34d4663927fb97b80edd75 (diff)
Memory leaks
Landmarks initialization were not correct git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2213 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ab7e0adb6f36b2ccfd52a8c652c1ea35258a7aa1
Diffstat (limited to 'src/cython/include/Euclidean_strong_witness_complex_interface.h')
-rw-r--r--src/cython/include/Euclidean_strong_witness_complex_interface.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/cython/include/Euclidean_strong_witness_complex_interface.h b/src/cython/include/Euclidean_strong_witness_complex_interface.h
index fc88a82d..67d85e18 100644
--- a/src/cython/include/Euclidean_strong_witness_complex_interface.h
+++ b/src/cython/include/Euclidean_strong_witness_complex_interface.h
@@ -48,27 +48,32 @@ class Euclidean_strong_witness_complex_interface {
public:
Euclidean_strong_witness_complex_interface(const std::vector<std::vector<double>>& landmarks,
- const std::vector<std::vector<double>>& witnesses)
- : landmarks_(landmarks.begin(), landmarks.end()),
- witnesses_(witnesses.begin(), witnesses.end()),
- witness_complex_(landmarks_, witnesses_) {
+ const std::vector<std::vector<double>>& witnesses) {
+ landmarks_.reserve(landmarks.size());
+ for(auto& landmark : landmarks)
+ landmarks_.emplace_back(landmark.begin(), landmark.end());
+ witness_complex_ = new Euclidean_strong_witness_complex<Dynamic_kernel>(landmarks_, witnesses);
+ }
+
+ ~Euclidean_strong_witness_complex_interface() {
+ delete witness_complex_;
}
void create_simplex_tree(Gudhi::Simplex_tree<>* simplex_tree, double max_alpha_square,
std::size_t limit_dimension) {
- witness_complex_.create_complex(*simplex_tree, max_alpha_square, limit_dimension);
+ witness_complex_->create_complex(*simplex_tree, max_alpha_square, limit_dimension);
simplex_tree->initialize_filtration();
}
void create_simplex_tree(Gudhi::Simplex_tree<>* simplex_tree, double max_alpha_square) {
- witness_complex_.create_complex(*simplex_tree, max_alpha_square);
+ witness_complex_->create_complex(*simplex_tree, max_alpha_square);
simplex_tree->initialize_filtration();
}
std::vector<double> get_point(unsigned vh) {
std::vector<double> vd;
if (vh < landmarks_.size()) {
- Point_d ph = witness_complex_.get_point(vh);
+ Point_d ph = witness_complex_->get_point(vh);
for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++)
vd.push_back(*coord);
}
@@ -77,8 +82,7 @@ class Euclidean_strong_witness_complex_interface {
private:
std::vector<Point_d> landmarks_;
- std::vector<Point_d> witnesses_;
- Euclidean_strong_witness_complex<Dynamic_kernel> witness_complex_;
+ Euclidean_strong_witness_complex<Dynamic_kernel>* witness_complex_;
};
} // namespace witness_complex