summaryrefslogtreecommitdiff
path: root/src/cython
diff options
context:
space:
mode:
Diffstat (limited to 'src/cython')
-rw-r--r--src/cython/cython/periodic_cubical_complex.pyx14
-rw-r--r--src/cython/doc/cubical_complex_user.rst45
-rw-r--r--src/cython/doc/fileformats.rst55
-rw-r--r--src/cython/doc/witness_complex_user.rst2
-rw-r--r--src/cython/include/Cubical_complex_interface.h6
5 files changed, 89 insertions, 33 deletions
diff --git a/src/cython/cython/periodic_cubical_complex.pyx b/src/cython/cython/periodic_cubical_complex.pyx
index 581c7b69..3025f125 100644
--- a/src/cython/cython/periodic_cubical_complex.pyx
+++ b/src/cython/cython/periodic_cubical_complex.pyx
@@ -33,7 +33,7 @@ __license__ = "GPL v3"
cdef extern from "Cubical_complex_interface.h" namespace "Gudhi":
cdef cppclass Periodic_cubical_complex_base_interface "Gudhi::Cubical_complex::Cubical_complex_interface<Gudhi::cubical_complex::Bitmap_cubical_complex_periodic_boundary_conditions_base<double>>":
- Periodic_cubical_complex_base_interface(vector[unsigned] dimensions, vector[double] top_dimensional_cells)
+ Periodic_cubical_complex_base_interface(vector[unsigned] dimensions, vector[double] top_dimensional_cells, vector[bool] periodic_dimensions)
Periodic_cubical_complex_base_interface(string perseus_file)
int num_simplices()
int dimension()
@@ -58,7 +58,7 @@ cdef class PeriodicCubicalComplex:
# Fake constructor that does nothing but documenting the constructor
def __init__(self, dimensions=None, top_dimensional_cells=None,
- perseus_file=''):
+ periodic_dimensions=None, perseus_file=''):
"""PeriodicCubicalComplex constructor from dimensions and
top_dimensional_cells or from a Perseus-style file name.
@@ -66,6 +66,8 @@ cdef class PeriodicCubicalComplex:
:type dimensions: list of int
:param top_dimensional_cells: A list of cells filtration values.
:type top_dimensional_cells: list of double
+ :param periodic_dimensions: A list of top dimensional cells periodicity value.
+ :type periodic_dimensions: list of boolean
Or
@@ -75,10 +77,10 @@ cdef class PeriodicCubicalComplex:
# The real cython constructor
def __cinit__(self, dimensions=None, top_dimensional_cells=None,
- perseus_file=''):
- if (dimensions is not None) and (top_dimensional_cells is not None) and (perseus_file is ''):
- self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells)
- elif (dimensions is None) and (top_dimensional_cells is None) and (perseus_file is not ''):
+ periodic_dimensions=None, perseus_file=''):
+ if (dimensions is not None) and (top_dimensional_cells is not None) and (periodic_dimensions is not None) and (perseus_file is ''):
+ self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells, periodic_dimensions)
+ elif (dimensions is None) and (top_dimensional_cells is None) and (periodic_dimensions is None) and (perseus_file is not ''):
if os.path.isfile(perseus_file):
self.thisptr = new Periodic_cubical_complex_base_interface(str.encode(perseus_file))
else:
diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst
index 2bfac62a..34598f02 100644
--- a/src/cython/doc/cubical_complex_user.rst
+++ b/src/cython/doc/cubical_complex_user.rst
@@ -81,23 +81,7 @@ filtration to all cubes. There are a number of constructors that can be used to
who want to use the code directly. They can be found in the :doc:`cubical_complex_ref`.
Currently one input from a text file is used. It uses a format used already in
`Perseus software <http://www.sas.upenn.edu/~vnanda/perseus/>`_ by Vidit Nanda.
-Below we are providing a description of the format. The first line contains a number d begin the dimension of the
-bitmap (2 in the example below). Next d lines are the numbers of top dimensional cubes in each dimensions (3 and 3
-in the example below). Next, in lexicographical order, the filtration of top dimensional cubes is given (1 4 6 8
-20 4 7 6 5 in the example below).
-
-.. figure::
- ../../doc/Bitmap_cubical_complex/exampleBitmap.png
- :alt: Example of a input data.
- :figclass: align-center
-
- Example of a input data.
-
-The input file for the following complex is:
-
-.. literalinclude:: ../../data/bitmap/cubicalcomplexdoc.txt
-
-.. centered:: ../../data/bitmap/cubicalcomplexdoc.txt
+The file format is described here: :doc:`Perseus <fileformats>`.
.. testcode::
@@ -124,15 +108,9 @@ Imposing periodic boundary conditions in the direction i, means that the left an
:math:`\mathcal{K}` are considered the same. In particular, if for a bitmap :math:`\mathcal{K}` periodic boundary
conditions are imposed in all directions, then complex :math:`\mathcal{K}` became n-dimensional torus. One can use
various constructors from the file Bitmap_cubical_complex_periodic_boundary_conditions_base.h to construct cubical
-complex with periodic boundary conditions. One can also use Perseus style input files. To indicate periodic boundary
-conditions in a given direction, then number of top dimensional cells in this direction have to be multiplied by -1.
-For instance:
-
-.. literalinclude:: ../../data/bitmap/periodiccubicalcomplexdoc.txt
-
-.. centered:: ../../data/bitmap/periodiccubicalcomplexdoc.txt
+complex with periodic boundary conditions.
-Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y.
+One can also use Perseus style input files (see :doc:`Perseus <fileformats>`) for the specific periodic case:
.. testcode::
@@ -149,6 +127,23 @@ the program output is:
Periodic cubical complex is of dimension 2 - 42 simplices.
+Or it can be defined as follows:
+
+.. testcode::
+
+ from gudhi import PeriodicCubicalComplex as pcc
+ periodic_cc = pcc(dimensions=[3,3],
+ top_dimensional_cells= [0, 0, 0, 0, 1, 0, 0, 0, 0],
+ periodic_dimensions=[True, False])
+ result_str = 'Periodic cubical complex is of dimension ' + repr(periodic_cc.dimension()) + ' - ' + \
+ repr(periodic_cc.num_simplices()) + ' simplices.'
+ print(result_str)
+
+the program output is:
+
+.. testoutput::
+
+ Periodic cubical complex is of dimension 2 - 42 simplices.
Examples.
---------
diff --git a/src/cython/doc/fileformats.rst b/src/cython/doc/fileformats.rst
index 156ef4e4..4f0b6f6d 100644
--- a/src/cython/doc/fileformats.rst
+++ b/src/cython/doc/fileformats.rst
@@ -23,7 +23,7 @@ Here is a simple sample file::
3 34.2 34.974
4 3. inf
-Other sample files can be found in the data/persistence_diagram folder.
+Other sample files can be found in the `data/persistence_diagram` folder.
Such files can be generated with
:meth:`gudhi.SimplexTree.write_persistence_diagram`, read with
@@ -31,3 +31,56 @@ Such files can be generated with
:meth:`gudhi.read_persistence_intervals_in_dimension` and displayed with
:meth:`gudhi.plot_persistence_barcode` or
:meth:`gudhi.plot_persistence_diagram`.
+
+Iso-cuboid
+**********
+
+Such a file describes an iso-oriented cuboid with diagonal opposite vertices
+(min_x, min_y, min_z,...) and (max_x, max_y, max_z, ...). The format is::
+
+ min_x min_y [min_z ...]
+ max_x max_y [max_z ...]
+
+Here is a simple sample file in the 3D case::
+
+ -1. -1. -1.
+ 1. 1. 1.
+
+
+Perseus
+*******
+
+This file format is the format used by the
+`Perseus software <http://www.sas.upenn.edu/~vnanda/perseus/>`_ by Vidit Nanda.
+The first line contains a number d begin the dimension of the bitmap (2 in the
+example below). Next d lines are the numbers of top dimensional cubes in each
+dimensions (3 and 3 in the example below). Next, in lexicographical order, the
+filtration of top dimensional cubes is given (1 4 6 8 20 4 7 6 5 in the example
+below).
+
+.. figure::
+ ../../doc/Bitmap_cubical_complex/exampleBitmap.png
+ :alt: Example of a input data.
+ :figclass: align-center
+
+ Example of a input data.
+
+The input file for the following complex is:
+
+.. literalinclude:: ../../data/bitmap/cubicalcomplexdoc.txt
+
+.. centered:: ../../data/bitmap/cubicalcomplexdoc.txt
+
+To indicate periodic boundary conditions in a given direction, then number of
+top dimensional cells in this direction have to be multiplied by -1. For
+instance:
+
+.. literalinclude:: ../../data/bitmap/periodiccubicalcomplexdoc.txt
+
+.. centered:: ../../data/bitmap/periodiccubicalcomplexdoc.txt
+
+
+Indicate that we have imposed periodic boundary conditions in the direction x,
+but not in the direction y.
+
+Other sample files can be found in the `data/bitmap` folder.
diff --git a/src/cython/doc/witness_complex_user.rst b/src/cython/doc/witness_complex_user.rst
index 29413269..99be5185 100644
--- a/src/cython/doc/witness_complex_user.rst
+++ b/src/cython/doc/witness_complex_user.rst
@@ -121,7 +121,7 @@ Example2: Computing persistence using strong relaxed witness complex
Here is an example of constructing a strong witness complex filtration and computing persistence on it:
-* :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py>`
+* :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py>`
Bibliography
============
diff --git a/src/cython/include/Cubical_complex_interface.h b/src/cython/include/Cubical_complex_interface.h
index 7c0148f1..fad92c2c 100644
--- a/src/cython/include/Cubical_complex_interface.h
+++ b/src/cython/include/Cubical_complex_interface.h
@@ -43,6 +43,12 @@ class Cubical_complex_interface : public Bitmap_cubical_complex<CubicalComplexOp
: Bitmap_cubical_complex<CubicalComplexOptions>(dimensions, top_dimensional_cells) {
}
+ Cubical_complex_interface(const std::vector<unsigned>& dimensions,
+ const std::vector<double>& top_dimensional_cells,
+ const std::vector<bool>& periodic_dimensions)
+ : Bitmap_cubical_complex<CubicalComplexOptions>(dimensions, top_dimensional_cells, periodic_dimensions) {
+ }
+
Cubical_complex_interface(const std::string& perseus_file)
: Bitmap_cubical_complex<CubicalComplexOptions>(perseus_file.c_str()) {
}