-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1005 from MClemot/ripsPersistenceDiagram
Rips persistence diagram
- Loading branch information
Showing
11 changed files
with
1,574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ttk_add_base_library(ripsPersistenceDiagram | ||
SOURCES | ||
RipsPersistenceDiagram.cpp | ||
ripserpy.cpp | ||
HEADERS | ||
RipsPersistenceDiagram.h | ||
ripser.h | ||
DEPENDS | ||
common | ||
) |
16 changes: 16 additions & 0 deletions
16
core/base/ripsPersistenceDiagram/RipsPersistenceDiagram.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <RipsPersistenceDiagram.h> | ||
|
||
ttk::RipsPersistenceDiagram::RipsPersistenceDiagram() { | ||
// inherited from Debug: prefix will be printed at the beginning of every msg | ||
this->setDebugMsgPrefix("RipsPersistenceDiagram"); | ||
} | ||
|
||
int ttk::RipsPersistenceDiagram::execute( | ||
const std::vector<std::vector<double>> &points, | ||
std::vector<std::vector<ripser::pers_pair_t>> &ph) const { | ||
|
||
ripser::ripser(points, SimplexMaximumDiameter, SimplexMaximumDimension, | ||
InputIsDistanceMatrix, ph); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/// \ingroup base | ||
/// \class ttk::RipsPersistenceDiagram | ||
/// \author Mattéo Clémot <matteo.clemot@univ-lyon1.fr> | ||
/// \date January 2024. | ||
/// | ||
/// \brief TTK base class that computes the persistence diagram of a Rips | ||
/// complex. | ||
/// | ||
/// This module defines the %RipsPersistenceDiagram class that takes a point | ||
/// cloud or a distance matrix and computes the persistence diagram of its Rips | ||
/// complex. | ||
/// | ||
/// \sa ttk::Triangulation | ||
/// \sa ttkRipsPersistenceDiagram.cpp %for a usage example. | ||
|
||
#pragma once | ||
|
||
// ttk common includes | ||
#include <Debug.h> | ||
|
||
#include <ripser.h> | ||
|
||
namespace ttk { | ||
|
||
/** | ||
* The RipsPersistenceDiagram class provides a method to call the code Ripser | ||
* in order to compute the persistence diagram of the Rips complex of the | ||
* input. | ||
*/ | ||
class RipsPersistenceDiagram : virtual public Debug { | ||
|
||
public: | ||
RipsPersistenceDiagram(); | ||
|
||
/** | ||
* @brief Main entry point | ||
* | ||
* @param[in] points Input point cloud in any dimension or input distance | ||
* matrix | ||
* @param[out] ph Computed Rips persistence diagram | ||
*/ | ||
int execute(const std::vector<std::vector<double>> &points, | ||
std::vector<std::vector<ripser::pers_pair_t>> &ph) const; | ||
|
||
protected: | ||
/** Max dimension of computed persistence diagram */ | ||
int SimplexMaximumDimension{1}; | ||
/** Rips threshold */ | ||
double SimplexMaximumDiameter{1.0}; | ||
/** is input a distance matrix */ | ||
int InputIsDistanceMatrix{0}; | ||
|
||
}; // RipsPersistenceDiagram class | ||
|
||
} // namespace ttk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/// \ingroup base | ||
/// \author Mattéo Clémot <matteo.clemot@univ-lyon1.fr> | ||
/// \date January 2024. | ||
|
||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cassert> | ||
#include <chrono> | ||
#include <cmath> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <numeric> | ||
#include <queue> | ||
#include <sstream> | ||
#include <unordered_map> | ||
|
||
namespace ripser { | ||
|
||
using value_t = double; | ||
using index_t = int64_t; | ||
using coefficient_t = uint16_t; | ||
|
||
using simplex_t = std::vector<index_t>; | ||
using simplex_diam_t = std::pair<simplex_t, value_t>; | ||
using pers_pair_t = std::pair<simplex_diam_t, simplex_diam_t>; | ||
|
||
void ripser(std::vector<std::vector<value_t>> points, | ||
value_t threshold, | ||
index_t dim_max, | ||
bool distanceMatrix, | ||
std::vector<std::vector<pers_pair_t>> &ph); | ||
|
||
} // namespace ripser |
Oops, something went wrong.