From 07b4360422ddeac4a7f577cc61eb368e1c7237d7 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 24 May 2016 09:03:51 +0000 Subject: Add Aurélien Alvarez's generator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1189 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5fe81e09f9f5efe8ea50ac34d9c012c70283a3e6 --- data/points/generator/README | 20 ++++- .../generator/aurelien_alvarez_surfaces_in_R8.py | 90 ++++++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100755 data/points/generator/aurelien_alvarez_surfaces_in_R8.py (limited to 'data') diff --git a/data/points/generator/README b/data/points/generator/README index e6b28eb0..41cb9165 100644 --- a/data/points/generator/README +++ b/data/points/generator/README @@ -1,10 +1,13 @@ -To build the example, run in a Terminal: +=========================== C++ generators ===================================== + +To build the C++ generators, run in a Terminal: cd /path-to-gudhi/ cmake . cd /path-to-data-generator/ make +=========================== hypergenerator ===================================== Example of use : @@ -24,3 +27,18 @@ Example of use : !! Warning: hypegenerator on cube is not available !! +===================== aurelien_alvarez_surfaces_in_R8 ========================== + +This generator is written in Python. + +This code generates points on a family of surfaces living in CP^2. You can move +in the family thanks to the parameter "degre". The parameter "nombrePoints" +allows to choose the number of points on the chosen surface. Finally, to compute +the points, we choose a chart in C^2 and take points randomly in the x-variable, +so that you may also modify the window for x in the complex plane (parameter +"module_x"). + +After that, the program computes points in C^2, then maps them in R^8, so that +the points live on a surface which is compact (which is not the case for the +intersection of the surface with C^2). We end off with a bunch of points on a +compact surface in R^8. diff --git a/data/points/generator/aurelien_alvarez_surfaces_in_R8.py b/data/points/generator/aurelien_alvarez_surfaces_in_R8.py new file mode 100755 index 00000000..57773c4c --- /dev/null +++ b/data/points/generator/aurelien_alvarez_surfaces_in_R8.py @@ -0,0 +1,90 @@ +# This file is part of the Gudhi Library. The Gudhi library +# (Geometric Understanding in Higher Dimensions) is a generic C++ +# library for computational topology. +# +# Author(s): Aurélien Alvarez +# +# Copyright (C) 2016 Université d'Orléans (France) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import numpy as np +import random +from math import factorial + +I = complex(0,1) + +################################################# +################################################# + +#Surface réelle d'équation x.conj(y)^d + y.conj(z)^d + z.conj(x)^d = 0 dans P2(C) +#Équation affine (z=1) multipliée par sa conjuguée (d = 2) : x.conj(x)^2.y^4 + 2x^3.conj(x).y^2 + y + conj(x)^2 + x^5 = 0 +def equationAffineSurfaceReelle(x): + polynome = [0]*(degre**2+1) + for k in range(degre+1): + polynome[k*degre] = (-1)**degre*x*factorial(degre)/(factorial(k)*factorial(degre-k))*x**(k*degre)*np.conjugate(x)**(degre-k) + polynome[-2] += 1 + polynome[-1] += np.conjugate(x)**degre + return polynome + +################################################# +################################################# + +def calculRacines(equation,nombrePoints,module_x): + racines = [[1,0,0],[0,1,0],[0,0,1]] + for _ in range(nombrePoints): + x = module_x*(2*random.random()-1+I*(2*random.random()-1)) + fool = [[[x,y,1],[y,1,x],[1,x,y]] for y in np.roots(equation(x)) if abs(x*np.conjugate(y)**degre+y+np.conjugate(x)**degre) < 0.0001] + for bar in fool: + racines += bar + return racines + +################################################# +################################################# + +def plongementDansR8(pointDansCP2): + z0 = pointDansCP2[0] + z1 = pointDansCP2[1] + z2 = pointDansCP2[2] + a = z0*np.conjugate(z0) + b = z1*np.conjugate(z1) + c = z2*np.conjugate(z2) + normeCarree = a+b+c + a = a/normeCarree + b = b/normeCarree + u = z0*np.conjugate(z1)/normeCarree + v = z0*np.conjugate(z2)/normeCarree + w = z1*np.conjugate(z2)/normeCarree + return [a.real,b.real,u.real,u.imag,v.real,v.imag,w.real,w.imag] + +def plongementListeDansR8(listePointsDansCP2): + listePointsDansR8 = [] + for point in listePointsDansCP2: + listePointsDansR8 += [plongementDansR8(point)] + return listePointsDansR8 + +################################################# +################################################# + +degre = 3 +nombrePoints = 10**4 +module_x = 10 + +with open("surface.txt","w") as fichier: + bar = calculRacines(equationAffineSurfaceReelle,nombrePoints,module_x) + listePoints = plongementListeDansR8(bar) + fichier.write(str(len(bar)) + "\n") + for point in listePoints: + fichier.write(str(point[0]) + " " + str(point[1]) + " " + str(point[2]) + " " + str(point[3]) + " " + str(point[4]) + " " + str(point[5]) + " " + str(point[6]) + " " + str(point[7]) + "\n") + -- cgit v1.2.3 From dc7e8e3267dcabe24c56af9377baa1466eec6fc3 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 8 Jun 2016 07:43:06 +0000 Subject: periodic_alpha_complex_3d_persistence modification for is_cuboid_3 to be customized through a file. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1261 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9862a35dcdfc0dbf0eff01375ea716f094833127 --- data/points/iso_cuboid_3_in_0_1.txt | 1 + src/Persistent_cohomology/example/CMakeLists.txt | 2 +- .../periodic_alpha_complex_3d_persistence.cpp | 24 +++++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 data/points/iso_cuboid_3_in_0_1.txt (limited to 'data') diff --git a/data/points/iso_cuboid_3_in_0_1.txt b/data/points/iso_cuboid_3_in_0_1.txt new file mode 100644 index 00000000..17f3c37b --- /dev/null +++ b/data/points/iso_cuboid_3_in_0_1.txt @@ -0,0 +1 @@ +0.0 0.0 0.0 1.0 1.0 1.0 diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index 186a6c33..b335fb3a 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -83,7 +83,7 @@ if(GMPXX_FOUND AND GMP_FOUND) target_link_libraries(custom_persistence_sort ${TBB_RELEASE_LIBRARY}) endif() add_test(alpha_complex_persistence_2_0_45 ${CMAKE_CURRENT_BINARY_DIR}/alpha_complex_persistence ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -m 0.45 -p 2) - add_test(periodic_alpha_complex_3d_persistence_2_0 ${CMAKE_CURRENT_BINARY_DIR}/periodic_alpha_complex_3d_persistence ${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off 2 0) + add_test(periodic_alpha_complex_3d_persistence_2_0 ${CMAKE_CURRENT_BINARY_DIR}/periodic_alpha_complex_3d_persistence ${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off ${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt 2 0) add_test(custom_persistence_sort ${CMAKE_CURRENT_BINARY_DIR}/custom_persistence_sort) else() diff --git a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp index b8e1097d..a199fea1 100644 --- a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp @@ -125,28 +125,28 @@ Vertex_list from(const Alpha_shape_3::Vertex_handle& vh) { void usage(char * const progName) { std::cerr << "Usage: " << progName << - " path_to_file_graph coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n"; + " path_to_file_graph path_to_iso_cuboid_3_file coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n"; exit(-1); } int main(int argc, char * const argv[]) { // program args management - if (argc != 4) { + if (argc != 5) { std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n"; usage(argv[0]); } int coeff_field_characteristic = 0; - int returnedScanValue = sscanf(argv[2], "%d", &coeff_field_characteristic); + int returnedScanValue = sscanf(argv[3], "%d", &coeff_field_characteristic); if ((returnedScanValue == EOF) || (coeff_field_characteristic <= 0)) { - std::cerr << "Error: " << argv[2] << " is not correct\n"; + std::cerr << "Error: " << argv[3] << " is not correct\n"; usage(argv[0]); } Filtration_value min_persistence = 0.0; - returnedScanValue = sscanf(argv[3], "%lf", &min_persistence); + returnedScanValue = sscanf(argv[4], "%lf", &min_persistence); if ((returnedScanValue == EOF) || (min_persistence < -1.0)) { - std::cerr << "Error: " << argv[3] << " is not correct\n"; + std::cerr << "Error: " << argv[4] << " is not correct\n"; usage(argv[0]); } @@ -160,11 +160,21 @@ int main(int argc, char * const argv[]) { usage(argv[0]); } + // Read iso_cuboid_3 information from file + std::ifstream iso_cuboid_str(argv[2]); + double x_min, y_min, z_min, x_max, y_max, z_max; + if (iso_cuboid_str.good()) { + iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max; + } else { + std::cerr << "Unable to read file " << argv[2] << std::endl; + usage(argv[0]); + } + // Retrieve the triangulation std::vector lp = off_reader.get_point_cloud(); // Define the periodic cube - P3DT3 pdt(PK::Iso_cuboid_3(0, 0, 0, 1, 1, 1)); + P3DT3 pdt(PK::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max)); // Heuristic for inserting large point sets (if pts is reasonably large) pdt.insert(lp.begin(), lp.end(), true); // As pdt won't be modified anymore switch to 1-sheeted cover if possible -- cgit v1.2.3 From 2ecd97ff50b01f864944443b3a2a8ea0220d9b10 Mon Sep 17 00:00:00 2001 From: cjamin Date: Fri, 10 Jun 2016 10:49:06 +0000 Subject: Missing link with Boost System git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1270 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 70e3dfb20af1a0b4f048f56fff0c85dbbde3f530 --- data/points/generator/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'data') diff --git a/data/points/generator/CMakeLists.txt b/data/points/generator/CMakeLists.txt index c01a380d..f892aa50 100644 --- a/data/points/generator/CMakeLists.txt +++ b/data/points/generator/CMakeLists.txt @@ -9,8 +9,9 @@ if(CGAL_FOUND) if (EIGEN3_FOUND) include( ${EIGEN3_USE_FILE} ) include_directories (BEFORE "../../include") - + add_executable ( hypergenerator hypergenerator.cpp ) + target_link_libraries(hypergenerator ${Boost_SYSTEM_LIBRARY}) add_test(hypergenerator_on_sphere_3000_10_5.0 ${CMAKE_CURRENT_BINARY_DIR}/hypergenerator on sphere onSphere.off 3000 10 5.0) add_test(hypergenerator_on_sphere_10000_3 ${CMAKE_CURRENT_BINARY_DIR}/hypergenerator on sphere onSphere.off 10000 3) add_test(hypergenerator_in_sphere_7000_12_10.8 ${CMAKE_CURRENT_BINARY_DIR}/hypergenerator in sphere inSphere.off 7000 12 10.8) -- cgit v1.2.3