├── .clang-format ├── .gitignore ├── CMakeLists.txt ├── COPYRIGHT ├── LICENSE ├── README.md ├── RIVET.pro ├── api.cpp ├── api.h ├── computation.cpp ├── computation.h ├── computationthread.cpp ├── computationthread.h ├── console.cpp ├── customspinbox.h ├── data ├── Avian_Influenza_Data │ ├── Avian_Recomb_500_Codensity_20th_Percentile.txt │ ├── Avian_Recomb_500_no_fun.txt │ └── avian_citations.txt ├── FIReps │ ├── firep_ex.txt │ ├── firep_ex2.txt │ ├── firep_ex3.txt │ ├── firep_ex4.txt │ └── firep_ex5.txt ├── Roadmap_Benchmark_Data │ ├── house104_RIVET_Codensity20thPercentile.txt_RIVET_Codensity20thPercentile │ ├── house104_RIVET_no_function.txt │ ├── network379_RIVET_Coeccentricity │ ├── roadmap_citations.txt │ ├── senate104_RIVET_Codensity20thPercentile.txt │ └── senate_RIVET_no_function.txt ├── Test_Bifiltrations │ ├── Simple_Bifiltration_Tests │ │ ├── bifiltration_empty.txt │ │ ├── bifiltration_single_vertex.txt │ │ ├── bifiltration_two_vertices_one_edge.txt │ │ ├── bifiltration_two_vertices_one_edge_multicritical.txt │ │ ├── bifiltration_two_vertices_one_edge_x_axis.txt │ │ ├── bifiltration_two_vertices_one_edge_y_axis.txt │ │ ├── bifiltration_two_vertices_x_axis.txt │ │ └── bifiltration_two_vertices_y_axis.txt │ ├── bifiltration1.txt │ ├── bifiltration2.txt │ ├── bifiltration3.txt │ ├── bifiltration4.txt │ └── bifiltration5.txt ├── Test_Point_Clouds │ ├── circle_300pts_density.csv │ ├── circle_300pts_density.txt │ ├── circle_300pts_nofunction.csv │ ├── circle_data_240pts.png │ ├── circle_data_240pts_codensity.txt │ ├── circle_data_600pts_codensity.txt │ ├── circle_data_60pts.png │ ├── circle_data_60pts_codensity.txt │ ├── points1.txt │ ├── points2.txt │ ├── points3.txt │ ├── points4.txt │ ├── points5.txt │ ├── points6.txt │ ├── ring_data_300pts_codensity.txt │ ├── square_data_210pts_codensity.txt │ ├── square_data_325pts_codensity.txt │ └── square_data_450pts_codensity.txt ├── convert.py └── metric_ex.txt ├── dataselectdialog.cpp ├── dataselectdialog.h ├── dataselectdialog.ui ├── dcel ├── anchor.cpp ├── anchor.h ├── arrangement.cpp ├── arrangement.h ├── arrangement_builder.cpp ├── arrangement_builder.h ├── arrangement_message.cpp ├── arrangement_message.h ├── barcode.cpp ├── barcode.h ├── barcode_template.cpp ├── barcode_template.h ├── dcel.cpp ├── dcel.h ├── grades.cpp ├── grades.h └── msgpack_adapters.h ├── debug.cpp ├── debug.h ├── docs ├── _static │ └── custom.js ├── about.rst ├── conf.py ├── gettingstarted.rst ├── images │ ├── RIVET_progress_box.png │ ├── RIVET_screenshot_circle300.png │ ├── RIVET_screenshot_circle300_balldensity.png │ ├── RIVET_screenshot_circle300v.png │ ├── circle300_point_plot.png │ ├── file_input_dialog.png │ ├── file_input_selections.png │ ├── flowchart.pdf │ ├── flowchart.svg │ ├── flowchart.tex │ └── line_diagram.png ├── index.rst ├── inputdata.rst ├── installing.rst ├── old_inputdata.rst ├── pipeline.rst ├── preliminaries.rst ├── rivetconsole.rst └── visualization.rst ├── interface ├── aboutmessagebox.cpp ├── aboutmessagebox.h ├── aboutmessagebox.ui ├── c_api.cpp ├── c_api.h ├── config_parameters.cpp ├── config_parameters.h ├── configuredialog.cpp ├── configuredialog.h ├── configuredialog.ui ├── console_interaction.cpp ├── console_interaction.h ├── control_dot.cpp ├── control_dot.h ├── data_reader.cpp ├── data_reader.h ├── file_input_reader.cpp ├── file_input_reader.h ├── file_writer.cpp ├── file_writer.h ├── input_manager.cpp ├── input_manager.h ├── input_parameters.h ├── persistence_bar.cpp ├── persistence_bar.h ├── persistence_diagram.cpp ├── persistence_diagram.h ├── persistence_dot.cpp ├── persistence_dot.h ├── progress.cpp ├── progress.h ├── progressdialog.cpp ├── progressdialog.h ├── progressdialog.ui ├── slice_diagram.cpp ├── slice_diagram.h ├── slice_line.cpp └── slice_line.h ├── main.cpp ├── math ├── bifiltration_data.cpp ├── bifiltration_data.h ├── bigraded_matrix.cpp ├── bigraded_matrix.h ├── bool_array.cpp ├── bool_array.h ├── distance_matrix.cpp ├── distance_matrix.h ├── firep.cpp ├── firep.h ├── grade.h ├── index_matrix.cpp ├── index_matrix.h ├── map_matrix.cpp ├── map_matrix.h ├── multi_betti.cpp ├── multi_betti.h ├── persistence_updater.cpp ├── persistence_updater.h ├── phat_mod │ ├── COPYING │ ├── COPYING.LESSER │ ├── README.md │ └── include │ │ └── phat │ │ ├── helpers │ │ ├── misc.h │ │ └── thread_local_storage.h │ │ └── representations │ │ └── vector_heap_mod.h ├── presentation.cpp ├── presentation.h ├── sparse_matrix.h ├── template_point.cpp ├── template_point.h ├── template_points_matrix.cpp └── template_points_matrix.h ├── numerics.cpp ├── numerics.h ├── pointer_comparator.h ├── run-tests.sh ├── test ├── .gitignore ├── CMakeLists.txt ├── catch.hpp ├── data_reader_tests.h ├── exact_ops.h ├── map_matrix_tests.h ├── output_test │ ├── correct │ ├── latest │ ├── readme.txt │ ├── run_tests.sh │ └── test_data │ │ ├── ring_data_300pts_codensity.txt │ │ ├── square_data_210pts_codensity.txt │ │ ├── square_data_325pts_codensity.txt │ │ ├── square_data_450pts_codensity.txt │ │ ├── test-bifiltration1.txt │ │ ├── test-firep_ex.txt │ │ ├── test-metric_ex.txt │ │ ├── test-metric_ex_2.txt │ │ ├── test-metric_ex_3.txt │ │ ├── test-points2.txt │ │ └── test-points2_1.txt ├── serialization_tests.h └── unit_tests.cpp ├── timer.cpp ├── timer.h ├── type_tag.h ├── visualizationwindow.cpp ├── visualizationwindow.h └── visualizationwindow.ui /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: WebKit 4 | AccessModifierOffset: -4 5 | AlignAfterOpenBracket: DontAlign 6 | AlignConsecutiveAssignments: false 7 | AlignConsecutiveDeclarations: false 8 | AlignEscapedNewlinesLeft: false 9 | AlignOperands: false 10 | AlignTrailingComments: false 11 | AllowAllParametersOfDeclarationOnNextLine: true 12 | AllowShortBlocksOnASingleLine: false 13 | AllowShortCaseLabelsOnASingleLine: false 14 | AllowShortFunctionsOnASingleLine: All 15 | AllowShortIfStatementsOnASingleLine: false 16 | AllowShortLoopsOnASingleLine: false 17 | AlwaysBreakAfterDefinitionReturnType: None 18 | AlwaysBreakAfterReturnType: None 19 | AlwaysBreakBeforeMultilineStrings: false 20 | AlwaysBreakTemplateDeclarations: false 21 | BinPackArguments: true 22 | BinPackParameters: true 23 | BraceWrapping: 24 | AfterClass: false 25 | AfterControlStatement: false 26 | AfterEnum: false 27 | AfterFunction: true 28 | AfterNamespace: false 29 | AfterObjCDeclaration: false 30 | AfterStruct: false 31 | AfterUnion: false 32 | BeforeCatch: false 33 | BeforeElse: false 34 | IndentBraces: false 35 | BreakBeforeBinaryOperators: All 36 | BreakBeforeBraces: WebKit 37 | BreakBeforeTernaryOperators: true 38 | BreakConstructorInitializersBeforeComma: true 39 | BreakAfterJavaFieldAnnotations: false 40 | BreakStringLiterals: true 41 | ColumnLimit: 0 42 | CommentPragmas: '^ IWYU pragma:' 43 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 44 | ConstructorInitializerIndentWidth: 4 45 | ContinuationIndentWidth: 4 46 | Cpp11BracedListStyle: false 47 | DerivePointerAlignment: false 48 | DisableFormat: false 49 | ExperimentalAutoDetectBinPacking: false 50 | ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] 51 | IncludeCategories: 52 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 53 | Priority: 2 54 | - Regex: '^(<|"(gtest|isl|json)/)' 55 | Priority: 3 56 | - Regex: '.*' 57 | Priority: 1 58 | IncludeIsMainRegex: '$' 59 | IndentCaseLabels: false 60 | IndentWidth: 4 61 | IndentWrappedFunctionNames: false 62 | JavaScriptQuotes: Leave 63 | JavaScriptWrapImports: true 64 | KeepEmptyLinesAtTheStartOfBlocks: true 65 | MacroBlockBegin: '' 66 | MacroBlockEnd: '' 67 | MaxEmptyLinesToKeep: 1 68 | NamespaceIndentation: Inner 69 | ObjCBlockIndentWidth: 4 70 | ObjCSpaceAfterProperty: true 71 | ObjCSpaceBeforeProtocolList: true 72 | PenaltyBreakBeforeFirstCallParameter: 19 73 | PenaltyBreakComment: 300 74 | PenaltyBreakFirstLessLess: 120 75 | PenaltyBreakString: 1000 76 | PenaltyExcessCharacter: 1000000 77 | PenaltyReturnTypeOnItsOwnLine: 60 78 | PointerAlignment: Left 79 | ReflowComments: true 80 | SortIncludes: true 81 | SpaceAfterCStyleCast: false 82 | SpaceBeforeAssignmentOperators: true 83 | SpaceBeforeParens: ControlStatements 84 | SpaceInEmptyParentheses: false 85 | SpacesBeforeTrailingComments: 1 86 | SpacesInAngles: false 87 | SpacesInContainerLiterals: true 88 | SpacesInCStyleCastParentheses: false 89 | SpacesInParentheses: false 90 | SpacesInSquareBrackets: false 91 | Standard: Cpp11 92 | TabWidth: 8 93 | UseTab: Never 94 | ... 95 | 96 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .qmake.stash 3 | GPATH 4 | GRTAGS 5 | GTAGS 6 | Makefile 7 | RIVET.app/ 8 | *.o 9 | .idea 10 | cmake_install.cmake 11 | *.txt 12 | moc_aboutmessagebox.cpp 13 | moc_computationthread.cpp 14 | moc_configuredialog.cpp 15 | moc_dataselectdialog.cpp 16 | moc_driver.cpp 17 | moc_persistence_diagram.cpp 18 | moc_progressdialog.cpp 19 | moc_slice_diagram.cpp 20 | moc_visualizationwindow.cpp 21 | ui_aboutmessagebox.h 22 | ui_configuredialog.h 23 | ui_dataselectdialog.h 24 | ui_progressdialog.h 25 | ui_visualizationwindow.h 26 | build 27 | cmake-build-* 28 | msgpack 29 | RIVET.pro.user 30 | moc_predefs.h 31 | docs/_build 32 | data/* 33 | *.png 34 | *.rivet 35 | python 36 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | RIVET Copyright 2014-2018 The RIVET Developers 2 | 3 | Principal contributors to RIVET: 4 | 5 | Bryn Keller 6 | Michael Lesnick 7 | Matthew L. Wright 8 | 9 | Other contributors to RIVET: 10 | 11 | Philip Nadolny 12 | Abdel-Rahman Madkour 13 | Simon Segert 14 | Dave Turner 15 | Alexander Yu 16 | Roy Zhao 17 | 18 | This version of RIVET uses some modified code from the PHAT 19 | repository for persistence computation by Ulrich Bauer, 20 | Michael Kerber, and Jan Reininghaus, Copyright 2013 IST Austria. 21 | 22 | 23 | RIVET is free software: you can redistribute it and/or modify 24 | it under the terms of the GNU General Public License as published by 25 | the Free Software Foundation, either version 3 of the License, or 26 | (at your option) any later version. 27 | 28 | This program is distributed in the hope that it will be useful, 29 | but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | GNU General Public License for more details. 32 | 33 | You should have received a copy of the GNU General Public License 34 | along with this program. If not, see . 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RIVET 2 | 3 | Program for the visualization and analysis of two-parameter persistent homology. 4 | 5 | The RIVET documentation lives here. 6 | 7 | RIVET is made available under the under the terms of the GNU General Public License, available here. The software is provided "as is," without warranty of any kind, even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for details. 8 | 9 | RIVET_screenshot 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /RIVET.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2014-06-24T12:13:18 4 | # 5 | #------------------------------------------------- 6 | 7 | macx { 8 | QMAKE_CXXFLAGS+="-g -gdwarf-2 -ftemplate-depth=1024 " 9 | QMAKE_POST_LINK='/usr/bin/dsymutil rivet_GUI.app/Contents/MacOS/rivet_GUI -o rivet_GUI.app/Contents/MacOS/rivet_GUI.dsym' 10 | } 11 | 12 | CONFIG += c++11 debug 13 | 14 | QT += core gui \ 15 | widgets 16 | 17 | TARGET = rivet_GUI 18 | TEMPLATE = app 19 | 20 | QMAKE_LIBDIR += /usr/local/lib #TODO: figure out how to generalize 21 | INCLUDEPATH += $$PWD/build/msgpack/src/msgpack_project/include 22 | 23 | SOURCES += main.cpp \ 24 | visualizationwindow.cpp \ 25 | dataselectdialog.cpp \ 26 | dcel/dcel.cpp \ 27 | dcel/arrangement.cpp \ 28 | interface/control_dot.cpp \ 29 | interface/input_manager.cpp \ 30 | interface/persistence_bar.cpp \ 31 | interface/persistence_diagram.cpp \ 32 | interface/persistence_dot.cpp \ 33 | interface/slice_diagram.cpp \ 34 | interface/slice_line.cpp \ 35 | math/bool_array.cpp \ 36 | math/index_matrix.cpp \ 37 | math/map_matrix.cpp \ 38 | #math/multi_betti.cpp \ 39 | dcel/barcode.cpp \ 40 | dcel/barcode_template.cpp \ 41 | dcel/anchor.cpp \ 42 | dcel/arrangement_message.cpp \ 43 | dcel/grades.cpp \ 44 | #math/persistence_updater.cpp \ 45 | math/template_points_matrix.cpp \ 46 | math/template_point.cpp \ 47 | interface/progressdialog.cpp \ 48 | computationthread.cpp \ 49 | interface/aboutmessagebox.cpp \ 50 | interface/configuredialog.cpp \ 51 | interface/config_parameters.cpp \ 52 | interface/file_input_reader.cpp \ 53 | interface/file_writer.cpp \ 54 | debug.cpp \ 55 | timer.cpp \ 56 | interface/console_interaction.cpp \ 57 | numerics.cpp \ 58 | 59 | 60 | HEADERS += visualizationwindow.h \ 61 | dataselectdialog.h \ 62 | debug.h \ 63 | dcel/dcel.h \ 64 | dcel/arrangement.h \ 65 | interface/control_dot.h \ 66 | interface/input_manager.h \ 67 | interface/persistence_bar.h \ 68 | interface/persistence_diagram.h \ 69 | interface/persistence_dot.h \ 70 | interface/slice_diagram.h \ 71 | interface/slice_line.h \ 72 | math/bool_array.h \ 73 | math/index_matrix.h \ 74 | math/map_matrix.h \ 75 | math/multi_betti.h \ 76 | dcel/barcode.h \ 77 | dcel/barcode_template.h \ 78 | dcel/anchor.h \ 79 | dcel/grades.h \ 80 | math/persistence_updater.h \ 81 | math/template_points_matrix.h \ 82 | math/template_point.h \ 83 | interface/progressdialog.h \ 84 | computationthread.h \ 85 | interface/input_parameters.h \ 86 | interface/aboutmessagebox.h \ 87 | interface/configuredialog.h \ 88 | interface/config_parameters.h \ 89 | interface/file_input_reader.h \ 90 | #driver.h \ 91 | interface/file_writer.h \ 92 | interface/console_interaction.h \ 93 | numerics.h \ 94 | customspinbox.h 95 | 96 | FORMS += visualizationwindow.ui \ 97 | dataselectdialog.ui \ 98 | interface/progressdialog.ui \ 99 | interface/aboutmessagebox.ui \ 100 | interface/configuredialog.ui 101 | 102 | -------------------------------------------------------------------------------- /api.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Bryn Keller on 11/16/17. 3 | // 4 | #include "api.h" 5 | 6 | std::unique_ptr from_istream(std::istream &file) { 7 | std::string type; 8 | std::getline(file, type); 9 | InputParameters params; 10 | TemplatePointsMessage templatePointsMessage; 11 | ArrangementMessage arrangementMessage; 12 | if (type == "RIVET_msgpack") { 13 | std::string buffer((std::istreambuf_iterator(file)), 14 | std::istreambuf_iterator()); 15 | 16 | msgpack::unpacker pac; 17 | pac.reserve_buffer( buffer.size() ); 18 | std::copy( buffer.begin(), buffer.end(), pac.buffer() ); 19 | pac.buffer_consumed( buffer.size() ); 20 | 21 | msgpack::object_handle oh; 22 | pac.next(oh); 23 | auto m1 = oh.get(); 24 | // std::cout << "params" << std::endl; 25 | m1.convert(params); 26 | pac.next(oh); 27 | auto m2 = oh.get(); 28 | // std::cout << "points" << std::endl; 29 | // break_stream stream; 30 | // std::cout.rdbuf(&stream); 31 | // std::cerr.rdbuf(&stream); 32 | m2.convert(templatePointsMessage); 33 | pac.next(oh); 34 | auto m3 = oh.get(); 35 | // std::cout << "arrangement message" << std::endl; 36 | m3.convert(arrangementMessage); 37 | 38 | } else { 39 | throw std::runtime_error("Expected a RIVET module invariants file"); 40 | } 41 | return from_messages(templatePointsMessage, arrangementMessage); 42 | } 43 | 44 | std::unique_ptr from_messages( 45 | const TemplatePointsMessage &templatePointsMessage, 46 | const ArrangementMessage &arrangementMessage) { 47 | // std::cout << "from_messages" << std::endl; 48 | std::unique_ptr result(new ComputationResult); 49 | result->arrangement.reset(arrangementMessage.to_arrangement()); 50 | //result->arrangement->test_consistency(); 51 | std::vector ex; 52 | const size_t* shape = templatePointsMessage.homology_dimensions.shape(); 53 | ex.assign(shape, shape + templatePointsMessage.homology_dimensions.num_dimensions()); 54 | result->homology_dimensions.resize(ex); 55 | result->homology_dimensions = templatePointsMessage.homology_dimensions; 56 | result->template_points = templatePointsMessage.template_points; 57 | return result; 58 | } 59 | 60 | std::vector> query_barcodes(const ComputationResult &computation, 61 | const std::vector> &offset_slopes) { 62 | 63 | Grades grades(computation.arrangement->x_exact, computation.arrangement->y_exact); 64 | std::vector> result; 65 | 66 | for (auto query : offset_slopes) { 67 | auto angle = query.first; 68 | auto offset = query.second; 69 | auto templ = computation.arrangement->get_barcode_template(angle, offset); 70 | result.push_back(templ.rescale(angle, offset, computation.template_points, grades)); 71 | } 72 | return result; 73 | } 74 | 75 | Bounds compute_bounds(const ComputationResult &computation_result) { 76 | const auto grades = Grades(computation_result.arrangement->x_exact, computation_result.arrangement->y_exact); 77 | const auto x_low = grades.x.front(); 78 | const auto y_low = grades.y.front(); 79 | const auto x_high = grades.x.back(); 80 | const auto y_high = grades.y.back(); 81 | return Bounds { 82 | x_low, 83 | y_low, 84 | x_high, 85 | y_high 86 | }; 87 | } 88 | -------------------------------------------------------------------------------- /api.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Bryn Keller on 11/16/17. 3 | // 4 | 5 | #ifndef RIVET_CONSOLE_API_H 6 | #define RIVET_CONSOLE_API_H 7 | 8 | #include "dcel/anchor.h" 9 | #include "dcel/arrangement.h" 10 | #include "dcel/barcode_template.h" 11 | #include "dcel/dcel.h" 12 | #include "type_tag.h" 13 | #include 14 | #include 15 | #include 16 | #include "dcel/msgpack_adapters.h" 17 | #include "computation.h" 18 | #include "dcel/dcel.h" 19 | #include "dcel/arrangement_message.h" 20 | #include 21 | 22 | std::unique_ptr from_messages( 23 | const TemplatePointsMessage &templatePointsMessage, 24 | const ArrangementMessage &arrangementMessage); 25 | 26 | std::vector> query_barcodes(const ComputationResult &computation, 27 | const std::vector> &offset_slopes); 28 | 29 | std::unique_ptr from_istream(std::istream &file); 30 | 31 | 32 | struct Bounds { 33 | double x_low; 34 | double y_low; 35 | double x_high; 36 | double y_high; 37 | }; 38 | 39 | Bounds compute_bounds(const ComputationResult &computation_result); 40 | 41 | #endif //RIVET_CONSOLE_API_H 42 | -------------------------------------------------------------------------------- /computation.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include "dcel/barcode_template.h" 24 | #include "dcel/dcel.h" 25 | #include "interface/input_manager.h" 26 | #include "interface/data_reader.h" 27 | #include "interface/input_parameters.h" 28 | #include "math/bifiltration_data.h" 29 | #include "math/firep.h" 30 | #include "math/template_point.h" 31 | #include "numerics.h" 32 | 33 | #include "boost/multi_array.hpp" 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | class Presentation; 40 | class MultiBetti; 41 | 42 | //TODO: Remove either this or InputData, since there's no need for both anymore now that RIVET_0 files aren't supported. 43 | class ComputationInput { 44 | protected: 45 | InputData data; 46 | 47 | public: 48 | std::vector x_exact; 49 | std::vector y_exact; 50 | std::string x_label; 51 | std::string y_label; 52 | 53 | bool x_reverse; 54 | bool y_reverse; 55 | BifiltrationData& bifiltration() 56 | { 57 | return *(data.bifiltration_data); 58 | } 59 | 60 | FIRep& rep() 61 | { 62 | return *(data.free_implicit_rep); 63 | } 64 | 65 | ComputationInput(InputData data) 66 | : data(data) 67 | , x_exact(data.x_exact) 68 | , y_exact(data.y_exact) 69 | , x_label(data.x_label) 70 | , y_label(data.y_label) 71 | , x_reverse(data.x_reverse) 72 | , y_reverse(data.y_reverse) 73 | { 74 | } 75 | }; 76 | 77 | struct ComputationResult { 78 | unsigned_matrix homology_dimensions; 79 | std::vector template_points; 80 | std::shared_ptr arrangement; 81 | //std::shared_ptr bifiltration; 82 | }; 83 | 84 | class Computation { 85 | public: 86 | //TODO: these signals are a little strange. It would be better to do away 87 | //with these, and to factor Computation::compute_raw into several functions 88 | //that can be called separately depending on the arguments to rivet_console. 89 | boost::signals2::signal)> arrangement_ready; 90 | boost::signals2::signal template_points_ready; 91 | boost::signals2::signal minpres_ready; 92 | Computation(int vrbsty, Progress& progress); 93 | ~Computation(); 94 | 95 | std::unique_ptr compute(InputData data, bool koszul); 96 | 97 | private: 98 | Progress& progress; 99 | 100 | const int verbosity; 101 | 102 | std::unique_ptr compute_raw(ComputationInput& input, bool koszul); 103 | 104 | void compute_min_pres_and_betti_nums(ComputationInput& input, MultiBetti& mb, Presentation& pres, std::unique_ptr& result); 105 | }; 106 | -------------------------------------------------------------------------------- /computationthread.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef COMPUTATIONTHREAD_H 22 | #define COMPUTATIONTHREAD_H 23 | 24 | //forward declarations 25 | class InputManager; 26 | struct InputParameters; 27 | class Arrangement; 28 | 29 | #include "dcel/barcode_template.h" 30 | #include "math/template_point.h" 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | typedef boost::multiprecision::cpp_rational exact; 37 | #include "boost/multi_array.hpp" 38 | typedef boost::multi_array unsigned_matrix; 39 | 40 | #include "dcel/arrangement_message.h" 41 | #include 42 | 43 | class ComputationThread : public QThread { 44 | Q_OBJECT 45 | 46 | friend class InputManager; //so that we don't have to pass all of the data structures from ComputationThread to InputManager 47 | 48 | public: 49 | ComputationThread(InputParameters& params, 50 | QObject* parent = 0); 51 | ~ComputationThread(); 52 | 53 | void compute(); 54 | 55 | std::shared_ptr message; 56 | 57 | signals: 58 | void advanceProgressStage(); 59 | void setProgressMaximum(unsigned max); 60 | void setCurrentProgress(unsigned current); 61 | void templatePointsReady(std::shared_ptr template_points); 62 | void arrangementReady(std::shared_ptr arrangement); 63 | 64 | protected: 65 | void run() Q_DECL_OVERRIDE; 66 | 67 | private: 68 | InputParameters& params; 69 | 70 | std::shared_ptr arrangement; 71 | 72 | void compute_from_file(); 73 | void unpack_message_fields(); 74 | bool is_precomputed(const std::string &file_name); 75 | void load_template_points_from_file(const std::string &file_name); 76 | void load_from_file(const std::string &file_name); 77 | }; 78 | 79 | //TODO: Move this somewhere. See comments on implementation for details. 80 | void write_msgpack_file(QString file_name, InputParameters const& params, TemplatePointsMessage const& message, ArrangementMessage const& arrangement); 81 | #endif // COMPUTATIONTHREAD_H 82 | -------------------------------------------------------------------------------- /customspinbox.h: -------------------------------------------------------------------------------- 1 | #ifndef CUSTOMSPINBOX_H 2 | #define CUSTOMSPINBOX_H 3 | #include 4 | 5 | //class for spin boxes used in visualization window 6 | class CustomSpinBox : public QDoubleSpinBox 7 | { 8 | public: 9 | explicit CustomSpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent) { 10 | 11 | } 12 | 13 | bool from_button=false; //whether the value change came from the up/down buttons (as opposed to typing the value) 14 | 15 | //called whenever the up or down button is pushed 16 | void stepBy(int steps){ 17 | from_button=true; 18 | QDoubleSpinBox::stepBy(steps); //this will change the value and thereby call CustomSpinBox::textFromValue 19 | from_button=false; 20 | } 21 | 22 | //this function controls the appearance of the text 23 | QString textFromValue(double val) const { 24 | 25 | 26 | QString str = QString::number(fabs(val), 'f', decimals() ); 27 | //take absolute value so that "-0" is not immediately corrected to "0" 28 | 29 | //make sure there is not a zero before the decimal point for numbers in (-1,1) 30 | if((val>-1&& val<0) ||(val>0&& val<1)){ 31 | str.replace("0.","."); 32 | } 33 | 34 | //add in the minus sign if the value is negative, or if the user was in the middle of typing 35 | //a negative value >-1 (e.g. -0.5) 36 | if(val<0 ||(!from_button && (lineEdit()->text().size()>0&& lineEdit()->text().at(0)=='-'))){ 37 | str="-"+str; 38 | } 39 | 40 | str.remove( QRegExp("0+$") ); // Remove any number of trailing 0's 41 | str.remove( QRegExp("\\.$") ); // If the last character is just a '.' then remove it 42 | 43 | return str; 44 | } 45 | }; 46 | 47 | 48 | #endif // CUSTOMSPINBOX_H 49 | -------------------------------------------------------------------------------- /data/Avian_Influenza_Data/avian_citations.txt: -------------------------------------------------------------------------------- 1 | The data files in this folder are adapted from a data file 2 | “pnas2013/avian_all_nt_concat_jukes_cantor.csv” available at 3 | 4 | https://github.com/RabadanLab/ph_datasets 5 | 6 | The associated paper is: 7 | 8 | “Topology of viral evolution,” Chan, J., Carlsson, G., and Rabadan, R. 9 | Proceedings of the National Academy of Sciences 110.46 (2013) 18566-18571. 10 | http://www.pnas.org/content/110/46/18566 -------------------------------------------------------------------------------- /data/FIReps/firep_ex.txt: -------------------------------------------------------------------------------- 1 | --datatype firep 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 2 2 0 7 | 3 2 ; 0 8 | 2 3 ; 0 1 9 | 1 1 ; 10 | 2 2 ; 11 | 12 | -------------------------------------------------------------------------------- /data/FIReps/firep_ex2.txt: -------------------------------------------------------------------------------- 1 | --datatype firep 2 | --xlabel parameter 1 3 | --ylabel parameter 2 4 | 5 | # data starts here 6 | 2 3 3 7 | 1 0 ; 0 1 2 8 | 0 1 ; 0 1 2 9 | 0 0 ; 1 2 10 | 0 0 ; 0 2 11 | 0 0 ; 0 1 -------------------------------------------------------------------------------- /data/FIReps/firep_ex3.txt: -------------------------------------------------------------------------------- 1 | --datatype firep 2 | --xlabel parameter 1 3 | --ylabel parameter 2 4 | 5 | # data starts here 6 | 2 5 4 7 | 1 0 ; 1 3 4 8 | 0 1 ; 0 1 2 9 | 0 0 ; 0 2 10 | 0 0 ; 1 2 11 | 0 0 ; 0 1 12 | 0 0 ; 1 3 13 | 0 0 ; 2 3 -------------------------------------------------------------------------------- /data/FIReps/firep_ex4.txt: -------------------------------------------------------------------------------- 1 | --datatype firep 2 | --xlabel parameter 1 3 | --ylabel parameter 2 4 | 5 | # data starts here 6 | 2 5 4 7 | 5 .2 ; 0 1 2 8 | .25 5 ; 2 3 4 9 | 10 | 0 0.1 ; 1 2 11 | 0.1 0 ; 0 2 12 | 0 0.2 ; 0 1 13 | 0.2 0 ; 0 3 14 | 0.25 0 ; 1 3 -------------------------------------------------------------------------------- /data/FIReps/firep_ex5.txt: -------------------------------------------------------------------------------- 1 | --datatype firep 2 | --xlabel parameter 1 3 | --ylabel parameter 2 4 | 5 | # data starts here 6 | 2 5 4 7 | .75 2 ; 0 1 2 8 | 2 .75 ; 2 3 4 9 | 0 0.1 ; 1 2 10 | 0.1 0 ; 0 2 11 | 0 0.2 ; 0 1 12 | 0.2 0 ; 0 3 13 | 0.25 0 ; 1 3 -------------------------------------------------------------------------------- /data/Roadmap_Benchmark_Data/roadmap_citations.txt: -------------------------------------------------------------------------------- 1 | The data files in this folder are adapted from Nina Otter’s repository of metric spaces, originally assembled for benchmarking persistent homology computations. Nina’s repository is available at: 2 | https://github.com/n-otter/PH-roadmap 3 | 4 | The corresponding paper, with references to the original sources of the data, is: 5 | 6 | “A roadmap for the computation of persistent homology,” Nina Otter, Mason A Porter, Ulrike Tillmann, Peter Grindrod, and Heather A Harrington, EPJ Data Science, 2017. 7 | https://link.springer.com/article/10.1140/epjds/s13688-017-0109-5 8 | 9 | -------------------------------------------------------------------------------- /data/Test_Bifiltrations/Simple_Bifiltration_Tests/bifiltration_empty.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | #empty bifiltration 7 | -------------------------------------------------------------------------------- /data/Test_Bifiltrations/Simple_Bifiltration_Tests/bifiltration_single_vertex.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | #single vertex bifiltration 7 | 0 ; 0 0 -------------------------------------------------------------------------------- /data/Test_Bifiltrations/Simple_Bifiltration_Tests/bifiltration_two_vertices_one_edge.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | #two incomparable vertices, one edge 7 | 1 ; 1 0 8 | 2 ; 0 1 9 | 1 2 ; 1 1 -------------------------------------------------------------------------------- /data/Test_Bifiltrations/Simple_Bifiltration_Tests/bifiltration_two_vertices_one_edge_multicritical.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | #two incomparable vertices, one edge 7 | 1 ; 1 0 8 | 2 ; 0 1 9 | 1 2 ; 2 1 1 2 -------------------------------------------------------------------------------- /data/Test_Bifiltrations/Simple_Bifiltration_Tests/bifiltration_two_vertices_one_edge_x_axis.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 1 ; 0 0 7 | 2 ; 1 0 8 | 1 2 ; 2 0 -------------------------------------------------------------------------------- /data/Test_Bifiltrations/Simple_Bifiltration_Tests/bifiltration_two_vertices_one_edge_y_axis.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 1 ; 0 0 7 | 2 ; 0 1 8 | 1 2 ; 0 2 -------------------------------------------------------------------------------- /data/Test_Bifiltrations/Simple_Bifiltration_Tests/bifiltration_two_vertices_x_axis.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 1 ; 0 0 7 | 2 ; 1 0 -------------------------------------------------------------------------------- /data/Test_Bifiltrations/Simple_Bifiltration_Tests/bifiltration_two_vertices_y_axis.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 1 ; 0 0 7 | 2 ; 0 1 -------------------------------------------------------------------------------- /data/Test_Bifiltrations/bifiltration1.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 0 ; 0 0 7 | 1 ; 0 0 8 | 2 ; 0 0 9 | 3 ; 0 0 10 | 0 1 ; 0 0 11 | 0 2 ; 0 0 12 | 1 2 ; 0 0 13 | 0 1 2 ; 1 0 14 | 1 3 ; 0 1 15 | 2 3 ; 0 1 16 | -------------------------------------------------------------------------------- /data/Test_Bifiltrations/bifiltration2.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 0 ; 0 0 7 | 3 ; 1 0 8 | 4 ; 1 0 9 | 1 ; 0 1 10 | 2 ; 0 1 11 | 0 3 ; 1 0 12 | 0 4 ; 1 0 13 | 3 4 ; 1 0 14 | 0 1 ; 0 1 15 | 0 2 ; 0 1 16 | 1 2 ; 0 1 17 | 0 1 2 ; 1 2 18 | 0 3 4 ; 2 1 19 | -------------------------------------------------------------------------------- /data/Test_Bifiltrations/bifiltration3.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 1 ; 0 0 7 | 2 ; 0 0 8 | 3 ; 0 0 9 | 4 ; 0 0 10 | 1 2 ; 1 0 11 | 2 3 ; 0 0 12 | 3 4 ; 0 1 13 | 14 | -------------------------------------------------------------------------------- /data/Test_Bifiltrations/bifiltration4.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 1 ; 2 0 7 | 2 ; 1 1 8 | 3 ; 0 2 9 | 1 2 ; 2 1 10 | 2 3 ; 1 2 11 | 1 3 ; 2 2 12 | 1 2 3 ; 3 3 13 | 4 ; 3 3 14 | 1 4 ; 3 3 15 | 2 4 ; 3 3 16 | 3 4 ; 3 3 17 | 1 2 4 ; 3 3 18 | 1 3 4 ; 3 3 19 | 2 3 4 ; 3 3 20 | 1 2 3 4 ; 3 3 21 | 5 ; 4 4 22 | 5 1 ; 5 5 23 | 5 2 ; 5 5 24 | 1 2 5 ; 6 6 25 | 26 | -------------------------------------------------------------------------------- /data/Test_Bifiltrations/bifiltration5.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 5 | # data starts here 6 | 1 ; 0 0 7 | 2 ; 0 0 8 | 3 ; 0 0 9 | 4 ; 0 0 10 | 1 2 ; 1 1 11 | 2 3 ; 1 1 12 | 3 4 ; 1 1 13 | 4 1 ; 1 1 14 | 1 3 ; 2 2 15 | 2 4 ; 2 2 16 | 1 2 3 ; 3 2 17 | 1 2 4 ; 2 3 18 | 1 3 4 ; 2 2 19 | 2 3 4 ; 3 3 -------------------------------------------------------------------------------- /data/Test_Point_Clouds/circle_300pts_nofunction.csv: -------------------------------------------------------------------------------- 1 | 1.57,2.40 2 | 1.21,2.70 3 | 0.79,-2.44 4 | -2.44,-2.24 5 | -2.54,-1.25 6 | 1.25,-2.74 7 | 0.24,3.04 8 | -0.77,3.25 9 | -1.30,2.42 10 | -2.09,1.74 11 | -1.16,-2.57 12 | -2.92,-0.20 13 | -2.57,-0.29 14 | -1.05,-3.38 15 | -1.24,2.80 16 | -0.35,-2.86 17 | -2.29,-1.31 18 | 2.84,0.35 19 | 0.73,-2.68 20 | 1.70,2.45 21 | 1.92,2.83 22 | 1.50,-2.66 23 | 2.45,0.30 24 | -0.48,-3.04 25 | 0.96,2.75 26 | 1.10,-2.35 27 | 2.94,1.36 28 | -1.21,2.77 29 | -2.45,-1.88 30 | -2.28,-2.19 31 | -2.32,2.03 32 | 2.27,1.75 33 | -2.53,-1.52 34 | 2.60,1.66 35 | -3.54,0.24 36 | -2.58,1.45 37 | 0.37,-3.41 38 | -2.31,-0.98 39 | -1.29,-2.49 40 | 3.03,-0.95 41 | 2.09,-2.35 42 | -1.42,-2.57 43 | -2.03,3.23 44 | 1.33,-2.51 45 | -2.05,2.57 46 | 1.15,2.39 47 | 2.09,1.85 48 | 0.95,-3.15 49 | 2.63,0.62 50 | 2.11,-2.54 51 | 2.71,-2.35 52 | 2.59,1.33 53 | -2.79,-1.46 54 | -2.71,0.20 55 | 1.41,-3.21 56 | -3.29,-0.81 57 | -1.49,-2.52 58 | -2.36,-1.68 59 | 2.34,-0.61 60 | 1.22,-2.35 61 | -2.48,-1.92 62 | -2.85,1.00 63 | -1.65,-1.45 64 | -1.89,-2.30 65 | -2.20,-1.84 66 | 0.40,-2.71 67 | 2.02,-1.65 68 | 0.84,2.82 69 | -2.95,1.65 70 | -2.38,-1.98 71 | 1.26,2.72 72 | 3.22,-1.27 73 | 2.38,1.16 74 | 3.20,-0.43 75 | 2.10,2.38 76 | 0.54,3.07 77 | -3.19,-0.68 78 | -1.39,3.15 79 | -2.83,0.90 80 | -1.39,-2.69 81 | 1.50,-2.26 82 | 1.99,2.46 83 | 2.03,-2.12 84 | -2.43,-2.02 85 | -2.18,2.23 86 | 1.12,-2.45 87 | -1.22,3.01 88 | 1.19,-2.96 89 | 0.44,2.74 90 | 1.26,-2.91 91 | 2.61,-1.59 92 | -2.41,-0.46 93 | -1.76,2.10 94 | -0.07,3.17 95 | -1.54,-2.65 96 | 1.25,3.19 97 | -2.10,-2.05 98 | -1.70,-2.23 99 | 1.39,-2.14 100 | -1.29,-2.24 101 | -0.67,2.98 102 | 1.97,2.45 103 | -2.93,-0.94 104 | -0.69,2.72 105 | -2.60,-0.87 106 | 1.43,-2.96 107 | -1.52,2.11 108 | -2.33,1.02 109 | 2.61,-0.82 110 | -2.13,1.89 111 | -0.54,3.20 112 | -0.19,-2.87 113 | -2.96,0.98 114 | -2.11,-2.18 115 | -2.85,0.95 116 | -2.42,-1.92 117 | -1.41,-2.17 118 | -3.07,0.57 119 | 2.04,2.22 120 | -1.61,2.39 121 | 0.65,2.53 122 | -2.86,-1.15 123 | 2.83,-1.17 124 | -0.65,2.63 125 | -0.16,-2.89 126 | 2.99,-0.39 127 | 1.97,-1.49 128 | 3.01,-1.10 129 | 1.61,2.38 130 | -0.26,-3.35 131 | 2.39,0.83 132 | -2.26,1.96 133 | -2.36,-2.16 134 | -2.17,1.85 135 | 0.48,2.68 136 | -2.20,1.92 137 | 0.79,-3.01 138 | 2.76,0.80 139 | 2.79,0.97 140 | -0.28,-2.49 141 | 1.55,-3.23 142 | -1.39,-2.09 143 | -3.50,-0.21 144 | -0.59,-2.56 145 | -1.18,2.32 146 | -1.26,-2.60 147 | 0.53,-2.69 148 | 1.35,-2.17 149 | -1.56,3.07 150 | -0.05,2.91 151 | -1.41,2.64 152 | 3.02,1.08 153 | -2.72,-0.59 154 | 2.55,0.62 155 | -2.70,0.55 156 | 2.60,1.49 157 | -1.86,-0.88 158 | -0.93,2.61 159 | 2.79,-0.90 160 | -0.52,2.75 161 | -2.19,1.35 162 | -3.06,-0.92 163 | -2.29,-1.93 164 | 2.24,2.41 165 | -1.53,1.96 166 | 2.72,0.62 167 | -2.61,-1.65 168 | 0.87,-2.45 169 | -1.20,3.10 170 | -2.86,1.02 171 | -3.52,1.20 172 | -2.18,1.82 173 | 1.24,-2.60 174 | 0.66,-2.55 175 | 0.69,3.46 176 | 0.71,-2.24 177 | 0.03,-2.89 178 | 0.35,-3.27 179 | -0.70,-2.81 180 | 1.50,-2.48 181 | -2.33,1.12 182 | -3.09,-0.20 183 | 1.02,-2.73 184 | 0.88,3.12 185 | 0.84,-3.08 186 | -3.24,-0.48 187 | 3.17,-0.70 188 | 0.10,3.65 189 | -2.23,2.22 190 | -2.56,1.11 191 | -2.68,-0.49 192 | 1.53,2.31 193 | -1.59,3.08 194 | -3.16,1.47 195 | 0.95,-2.45 196 | -1.36,-2.11 197 | -2.60,1.65 198 | -1.60,2.55 199 | 2.28,-2.20 200 | -1.52,2.64 201 | 2.24,-5.09 202 | -2.55,3.86 203 | -4.29,-2.14 204 | 3.54,0.05 205 | -3.70,5.18 206 | 3.29,-1.68 207 | -4.74,5.98 208 | 1.55,-3.42 209 | 2.61,5.73 210 | 3.34,5.11 211 | 2.72,-5.77 212 | 4.34,3.71 213 | 5.09,3.07 214 | 4.95,-1.23 215 | -1.56,0.74 216 | 4.31,4.98 217 | 0.62,-3.56 218 | -4.44,-2.36 219 | -2.26,4.37 220 | -3.09,-1.30 221 | -3.19,2.87 222 | 0.66,4.31 223 | 4.53,3.62 224 | 4.56,1.09 225 | -1.05,3.86 226 | -5.97,3.37 227 | 3.25,-5.26 228 | -5.99,-3.34 229 | -2.71,-5.91 230 | 5.86,0.38 231 | 0.31,-5.95 232 | -2.17,2.67 233 | -0.71,5.74 234 | 1.70,-5.84 235 | -4.71,2.83 236 | -3.69,-0.29 237 | 3.65,-0.83 238 | -0.08,-5.94 239 | 3.91,4.74 240 | -4.21,4.85 241 | 0.57,0.01 242 | 5.50,4.49 243 | 2.32,5.66 244 | -3.48,0.83 245 | 1.19,1.09 246 | -5.01,3.18 247 | 2.60,3.56 248 | -4.64,-0.52 249 | 2.80,5.89 250 | 4.22,4.57 251 | 2.46,-5.02 252 | -4.53,-4.19 253 | 1.03,5.13 254 | -2.47,4.48 255 | 1.69,-3.38 256 | 3.79,-2.29 257 | -4.83,-0.16 258 | -0.66,0.74 259 | -1.78,0.06 260 | 4.03,-0.83 261 | 3.89,-1.22 262 | -2.45,-4.01 263 | 5.95,2.46 264 | 4.61,2.34 265 | 3.00,-4.28 266 | 2.67,-0.12 267 | 5.58,-5.32 268 | -0.75,4.89 269 | -0.93,-0.01 270 | -0.79,4.18 271 | -4.01,-0.83 272 | -2.48,-5.19 273 | 3.08,5.69 274 | -1.40,-3.59 275 | -0.07,-1.94 276 | -5.89,-2.05 277 | -0.10,-2.87 278 | 1.11,-0.97 279 | 0.43,-3.78 280 | -2.27,-2.26 281 | -4.78,4.57 282 | 0.77,-0.13 283 | 5.94,-2.80 284 | -2.28,-1.75 285 | -4.96,-3.32 286 | 3.97,0.85 287 | 1.49,-5.88 288 | 5.03,4.94 289 | -1.62,-1.25 290 | -0.88,5.46 291 | -4.96,2.61 292 | 0.33,-3.22 293 | -3.73,5.32 294 | 0.26,2.60 295 | -2.84,-3.65 296 | -2.14,-1.37 297 | 5.65,-0.45 298 | 1.67,0.59 299 | -5.31,3.26 300 | -1.52,-4.94 -------------------------------------------------------------------------------- /data/Test_Point_Clouds/circle_data_240pts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/data/Test_Point_Clouds/circle_data_240pts.png -------------------------------------------------------------------------------- /data/Test_Point_Clouds/circle_data_60pts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/data/Test_Point_Clouds/circle_data_60pts.png -------------------------------------------------------------------------------- /data/Test_Point_Clouds/circle_data_60pts_codensity.txt: -------------------------------------------------------------------------------- 1 | --datatype points_fn 2 | --maxdist 1000 3 | --xlabel [+] codensity 4 | 5 | # function values 6 | 6.0000 2.0000 7.0000 6.0000 8.0000 8.0000 8.0000 6.0000 7.0000 7.0000 8.0000 6.0000 9.0000 7.0000 7.0000 9.0000 6.0000 1.0000 9.0000 4.0000 7.0000 9.0000 12.0000 6.0000 10.0000 2.0000 7.0000 4.0000 4.0000 9.0000 7.0000 9.0000 7.0000 5.0000 9.0000 9.0000 9.0000 6.0000 5.0000 4.0000 9.0000 9.0000 9.0000 5.0000 5.0000 8.0000 6.0000 4.0000 4.0000 1.0000 11.0000 6.0000 7.0000 11.0000 9.0000 8.0000 4.0000 6.0000 9.0000 6.0000 7 | 8 | # data starts here 9 | -3.8439 -0.6973 10 | 1.1527 0.3861 11 | 0.1530 -3.5394 12 | -2.6580 -1.9822 13 | 1.6725 -2.0966 14 | 3.5813 -0.2643 15 | 3.3843 -1.6059 16 | -3.2684 2.0882 17 | 3.3568 0.0072 18 | -3.3957 -0.8919 19 | 0.6370 2.3420 20 | 0.3969 2.0307 21 | -1.2712 2.4639 22 | 2.6018 1.7909 23 | -0.0590 -3.8078 24 | -0.0218 -2.3280 25 | -2.4889 -0.6943 26 | -2.9072 4.7021 27 | 1.2219 -2.1475 28 | -4.3818 -1.5025 29 | 3.6820 -1.0062 30 | 1.9746 -1.5751 31 | -1.8048 2.2819 32 | -2.6982 -0.8097 33 | -1.9421 2.7937 34 | -2.9825 -2.9012 35 | 0.4643 -1.5394 36 | -0.1223 -4.7186 37 | 2.5801 2.5975 38 | 1.1130 -2.2758 39 | 2.8568 0.4552 40 | -2.7954 1.6668 41 | -0.3790 -3.2296 42 | 0.7875 -3.9428 43 | -2.6388 2.9078 44 | -0.0869 -2.6937 45 | 2.2525 -1.8100 46 | 0.1683 3.6198 47 | 2.1294 2.2561 48 | 0.6187 3.9173 49 | -1.4204 1.9547 50 | -0.7853 3.3090 51 | 2.9141 -1.4279 52 | 3.9675 1.3254 53 | -1.5505 -1.0208 54 | 1.5614 2.5624 55 | 1.6060 -2.5876 56 | 0.4998 0.8770 57 | -4.0605 -0.0561 58 | 5.3878 -0.0227 59 | -1.7234 2.2101 60 | 3.1031 0.9456 61 | 0.5897 2.5375 62 | -2.6645 1.9917 63 | -1.3434 2.3157 64 | 0.3724 2.8896 65 | 4.0277 -1.7094 66 | -0.9292 -2.0819 67 | 2.4397 -0.5920 68 | -2.7154 1.1153 69 | -------------------------------------------------------------------------------- /data/Test_Point_Clouds/points1.txt: -------------------------------------------------------------------------------- 1 | --datatype points_fn 2 | --maxdist 4.1 3 | --xlabel birth 4 | 5 | # function values 6 | 0 0 0 0 0 7 | 8 | # data starts here 9 | 0.3 1.5 10 | 4.2 3.8 11 | 5.6 2.3 12 | 2.9 5.1 13 | 3.3 2.0 14 | -------------------------------------------------------------------------------- /data/Test_Point_Clouds/points2.txt: -------------------------------------------------------------------------------- 1 | --datatype points_fn 2 | --maxdist 3.1 3 | --xlabel time 4 | 5 | # function values 6 | 1 3.2 2 4 2.5 2.4 2 7 | 8 | # data starts here 9 | 0.3 1.5 2.1 10 | 4.2 3.8 4.9 11 | 5.6 2.3 6 12 | 2.9 5.1 3.3 13 | 3.3 2.0 2.5 14 | 4.1 1.1 2.3 15 | 1.1 1.3 1.7 16 | -------------------------------------------------------------------------------- /data/Test_Point_Clouds/points3.txt: -------------------------------------------------------------------------------- 1 | #testing comments 2 | 3 | --datatype points_fn 4 | 5 | --maxdist 4.5 6 | --xlabel birth time 7 | 8 | # function values 9 | 1 3 4 2 2 2 10 | 11 | # data starts here 12 | 13 | #now the data 14 | 1 2 15 | 1 5 16 | 2 4 17 | 2 7 18 | 1 8 19 | 5 4 20 | -------------------------------------------------------------------------------- /data/Test_Point_Clouds/points4.txt: -------------------------------------------------------------------------------- 1 | --datatype points_fn 2 | --maxdist 4.5 3 | --xlabel birth time 4 | 5 | # function values 6 | 1 3 4 2 2 2 4 1 7 | 8 | # data starts here 9 | 1 2 10 | 1 5 11 | 2 4 12 | 2 7 13 | 1 8 14 | 5 4 15 | 5 7 16 | 4 2 17 | -------------------------------------------------------------------------------- /data/Test_Point_Clouds/points5.txt: -------------------------------------------------------------------------------- 1 | --datatype points_fn 2 | --maxdist 4.5 3 | --xlabel birth time 4 | 5 | # function values 6 | 1 1 1 1 2 7 | 8 | # data starts here 9 | 1 5 10 | 2 7 11 | 1 8 12 | 5 4 13 | 2 4 14 | -------------------------------------------------------------------------------- /data/Test_Point_Clouds/points6.txt: -------------------------------------------------------------------------------- 1 | --datatype points_fn 2 | --maxdist 100 3 | --xlabel time 4 | 5 | # function values: examples of RIVET's scientific notation input 6 | 1.23e+006 2.34e-006 3.2 2e4 -5.1e-1 7e+02 -4.02e2 3 7 | 8 | # data starts here 9 | 0 0 10 | 0 1 11 | 0 10 12 | 10 0 13 | 10 10 14 | 0 0 15 | 1 0 16 | 1 1 17 | -------------------------------------------------------------------------------- /data/metric_ex.txt: -------------------------------------------------------------------------------- 1 | --datatype metric_fn 2 | #x-axis label 3 | --xlabel function values 4 | 5 | #y-axis label 6 | --ylabel distance 7 | 8 | #max distance to be a 1-simplex 9 | --maxdist 3 10 | 11 | #function values for five points 12 | 0 1 0.5 1 0.7 13 | 14 | # data starts here 15 | 16 | #distances 17 | 0.2 2.5 3.4 0.5 18 | 0.4 2 2.8 19 | 0.6 4 20 | 1 21 | 22 | -------------------------------------------------------------------------------- /dataselectdialog.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef DATASELECTDIALOG_H 22 | #define DATASELECTDIALOG_H 23 | 24 | //forward declarations 25 | struct InputParameters; 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | namespace Ui { 35 | class DataSelectDialog; 36 | } 37 | 38 | class DataSelectDialog : public QDialog { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit DataSelectDialog(InputParameters& params, QWidget* parent = 0); 43 | ~DataSelectDialog(); 44 | 45 | signals: 46 | void dataSelected(); 47 | 48 | protected: 49 | void closeEvent(QCloseEvent* event); 50 | void showEvent(QShowEvent* event); 51 | 52 | private slots: 53 | void on_computeButton_clicked(); 54 | void on_openFileButton_clicked(); 55 | void on_maxDistHelp_clicked(); 56 | 57 | void on_filterComboBox_currentIndexChanged(int index); 58 | void on_functionComboBox_currentIndexChanged(int index); 59 | void on_dataTypeComboBox_currentIndexChanged(int index); 60 | 61 | private: 62 | Ui::DataSelectDialog* ui; 63 | 64 | InputParameters& params; 65 | 66 | void invalid_file(const QString& message); 67 | void detect_file_type(); 68 | 69 | void parse_args(); 70 | 71 | int to_skip; 72 | 73 | void parse_points_old(); 74 | void parse_metric_old(); 75 | void parse_bifiltration_old(); 76 | void parse_firep_old(); 77 | 78 | bool data_selected; //false until user clicks "compute" button 79 | }; 80 | 81 | #endif // DATASELECTDIALOG_H 82 | -------------------------------------------------------------------------------- /dcel/anchor.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "anchor.h" 22 | #include "math/template_points_matrix.h" 23 | #include 24 | 25 | Anchor::Anchor(TemplatePointsMatrixEntry* e) 26 | : x_coord(e->x) 27 | , y_coord(e->y) 28 | , entry(e) 29 | , above_line(true) 30 | { 31 | } 32 | 33 | Anchor::Anchor(unsigned x, unsigned y) 34 | : x_coord(x) 35 | , y_coord(y) 36 | , entry() 37 | , dual_line() 38 | , position(0) 39 | , above_line(false) 40 | { 41 | } 42 | 43 | std::ostream& operator<<(std::ostream& stream, const Anchor& anchor) 44 | { 45 | stream << "Anchor(" << anchor.get_x() << ", " << anchor.get_y() << ")"; 46 | return stream; 47 | } 48 | 49 | Anchor::Anchor() 50 | : x_coord(0) 51 | , y_coord(0) 52 | , entry() 53 | , dual_line() 54 | , position() 55 | , above_line(false) 56 | , weight(0) 57 | { 58 | } 59 | 60 | bool Anchor::operator==(const Anchor& other) const 61 | { 62 | return (x_coord == other.x_coord && y_coord == other.y_coord); 63 | } 64 | 65 | bool Anchor::comparable(const Anchor& other) const //tests whether two Anchors are (strongly) comparable 66 | { 67 | return (y_coord > other.get_y() && x_coord > other.get_x()) || (y_coord < other.get_y() && x_coord < other.get_x()); 68 | } 69 | 70 | unsigned Anchor::get_x() const 71 | { 72 | return x_coord; 73 | } 74 | 75 | unsigned Anchor::get_y() const 76 | { 77 | return y_coord; 78 | } 79 | 80 | void Anchor::set_line(Halfedge* e) 81 | { 82 | dual_line = e; 83 | } 84 | 85 | Halfedge* Anchor::get_line() const 86 | { 87 | return dual_line; 88 | } 89 | 90 | void Anchor::set_position(unsigned p) 91 | { 92 | position = p; 93 | } 94 | 95 | unsigned Anchor::get_position() const 96 | { 97 | return position; 98 | } 99 | 100 | bool Anchor::is_above() 101 | { 102 | return above_line; 103 | } 104 | 105 | void Anchor::toggle() 106 | { 107 | above_line = !above_line; 108 | } 109 | 110 | TemplatePointsMatrixEntry* Anchor::get_entry() 111 | { 112 | return entry; 113 | } 114 | 115 | void Anchor::set_weight(unsigned long w) 116 | { 117 | weight = w; 118 | } 119 | 120 | unsigned long Anchor::get_weight() 121 | { 122 | return weight; 123 | } 124 | -------------------------------------------------------------------------------- /dcel/anchor.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | /** 21 | * \class Anchor 22 | * \brief Stores an Anchor: a bigrade along with a pointer to the line representing the Anchor in the arrangement 23 | * \author Matthew L. Wright 24 | * \date March 2014 25 | */ 26 | 27 | #ifndef __ANCHOR_H__ 28 | #define __ANCHOR_H__ 29 | 30 | #include 31 | 32 | //forward declarations 33 | class Halfedge; 34 | struct TemplatePointsMatrixEntry; 35 | 36 | class Anchor { 37 | public: 38 | Anchor(TemplatePointsMatrixEntry* e); //default constructor 39 | Anchor(unsigned x, unsigned y); //constructor, requires only x- and y-coordinates 40 | Anchor(); //For serialization 41 | 42 | bool operator==(const Anchor& other) const; //equality operator 43 | 44 | bool comparable(const Anchor& other) const; //tests whether two Anchors are (strongly) comparable 45 | 46 | unsigned get_x() const; //get the discrete x-coordinate 47 | unsigned get_y() const; //get the discrete y-coordinate 48 | 49 | void set_line(Halfedge* e); //set the pointer to the line corresponding to this Anchor in the arrangement 50 | Halfedge* get_line() const; //get the pointer to the line corresponding to this Anchor in the arrangement 51 | 52 | void set_position(unsigned p); //sets the relative position of the Anchor line at the sweep line, used for Bentley-Ottmann DCEL construction algorithm 53 | unsigned get_position() const; //gets the relative position of the Anchor line at the sweep line, used for Bentley-Ottmann DCEL construction algorithm 54 | 55 | bool is_above(); //returns true iff this Anchor is above the current slice line, used for the vineyard-update process of storing persistence data in cells of the arrangement 56 | void toggle(); //toggles above/below state of this Anchor; called whever the slice line crosses this Anchor in the vineyard-update process of storing persistence data 57 | 58 | TemplatePointsMatrixEntry* get_entry(); //accessor 59 | 60 | void set_weight(unsigned long w); //sets the estimate of the cost of updating the RU-decomposition when crossing this anchor 61 | unsigned long get_weight(); //returns estimate of the cost of updating the RU-decomposition when crossing this anchor 62 | 63 | private: 64 | unsigned x_coord; //discrete x-coordinate 65 | unsigned y_coord; //discrete y-coordinate 66 | 67 | TemplatePointsMatrixEntry* entry; //TemplatePointsMatrixEntry at the position of this anchor 68 | 69 | Halfedge* dual_line; //pointer to left-most halfedge corresponding to this Anchor in the arrangement 70 | unsigned position; //relative position of Anchor line at sweep line, used for Bentley-Ottmann DCEL construction algorithm 71 | bool above_line; //true iff this Anchor is above the current slice line, used for the vineyard-update process of storing persistence data in cells of the arrangement 72 | unsigned long weight; //estimate of the cost of updating the RU-decomposition when crossing this anchor 73 | }; 74 | 75 | template 76 | struct AnchorComparator { 77 | 78 | public: 79 | bool operator()(const T& lhs, const T& rhs) const //returns true if lhs comes before rhs 80 | { 81 | if (lhs.get_y() > rhs.get_y()) //first compare y-coordinates (reverse order) 82 | return true; 83 | else if (lhs.get_y() < rhs.get_y()) 84 | return false; 85 | return lhs.get_x() < rhs.get_x(); 86 | } 87 | }; 88 | 89 | struct Anchor_LeftComparator : AnchorComparator { 90 | }; 91 | 92 | #endif // __ANCHOR_H__ 93 | -------------------------------------------------------------------------------- /dcel/arrangement_builder.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | // 21 | // Created by Bryn Keller on 6/28/16. 22 | // Modifications by Mike Lesnick April 18, 2018. 23 | // 24 | 25 | #ifndef RIVET_CONSOLE_ARRANGEMENT_BUILDER_H 26 | #define RIVET_CONSOLE_ARRANGEMENT_BUILDER_H 27 | 28 | #include "dcel/arrangement.h" 29 | #include "interface/progress.h" 30 | #include "math/firep.h" 31 | #include 32 | 33 | class ArrangementBuilder { 34 | public: 35 | ArrangementBuilder(unsigned verbosity); 36 | 37 | //builds the DCEL arrangement, computes and stores persistence data 38 | //also stores ordered list of xi support points in the supplied vector 39 | //precondition: the constructor has already created the boundary of the arrangement 40 | std::shared_ptr build_arrangement(FIRep& fir, 41 | std::vector x_exact, 42 | std::vector y_exact, 43 | std::vector& template_points, 44 | Progress& progress); 45 | 46 | //builds the DCEL arrangement from the supplied xi support points, but does NOT compute persistence data 47 | std::shared_ptr build_arrangement( 48 | std::vector x_exact, 49 | std::vector y_exact, 50 | std::vector& template_points, std::vector& barcode_templates, Progress& progress); 51 | 52 | private: 53 | unsigned verbosity; 54 | void build_interior(Arrangement& arrangement); 55 | //builds the interior of DCEL arrangement using a version of the Bentley-Ottmann algorithm 56 | //precondition: all achors have been stored via find_anchors() 57 | void find_edge_weights(Arrangement& arrangement, PersistenceUpdater& updater); 58 | void find_path(Arrangement& arrangement, std::vector& pathvec); 59 | void find_subpath(Arrangement& arrangement, unsigned cur_node, std::vector>& adj, std::vector& pathvec); 60 | 61 | typedef std::vector> NodeAdjacencyList; 62 | 63 | /* technical function to convert an undirected tree into a directed representation 64 | a simplified version of a function formerly called sortAdjacencies 65 | though this name did not fully capture what the function did.) 66 | input: 67 | adjList: list of all adjacencies in the tree; adjList[a] = b iff nodes a and b are adjacent 68 | start: index of the node in the tree that will be regarded as root 69 | output: children[i] is a vector of indexes of the children of node i 70 | 71 | NOTE: unlike its predecessor sortAdjacencies, treeToDirectedRep does not 72 | sort children in decreasing rder of branch weight. That sorting was 73 | introduced to speed up barcode template computation, but the 74 | implementation was problematic and causing a memory issue. For now, I have 75 | implemented the quickest fix, which is to do away with the sorting altogether. 76 | I don't expect this to impact the performance of RIVET signicantly, 77 | especially since the cost of the barcode template computation is often 78 | negligible compared to that of computing a mimimal presentation. 79 | -Mike Lesnick, April 18 2018. 80 | */ 81 | void tree_to_directed_tree(std::vector& adj_list, unsigned start, std::vector>& children); 82 | }; 83 | 84 | #endif //RIVET_CONSOLE_ARRANGEMENT_BUILDER_H 85 | -------------------------------------------------------------------------------- /dcel/barcode.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "barcode.h" 22 | 23 | #include 24 | #include 25 | 26 | MultiBar::MultiBar(double b, double d, unsigned m) 27 | : birth(b) 28 | , death(d) 29 | , multiplicity(m) 30 | { 31 | } 32 | 33 | MultiBar::MultiBar(const MultiBar& other) 34 | : birth(other.birth) 35 | , death(other.death) 36 | , multiplicity(other.multiplicity) 37 | { 38 | } 39 | 40 | //comparison operator for sorting long bars first 41 | //uses approximate comparisons to avoid "flickering" of bars of nearly equal length 42 | bool MultiBar::operator<(const MultiBar other) const 43 | { 44 | double epsilon = pow(10, -8); 45 | 46 | //first, sort by length of bar 47 | if ((death - birth) > (other.death - other.birth + epsilon)) 48 | return true; 49 | 50 | //if bars have (almost) the same length, then sort by birth time 51 | if ((death - birth) >= (other.death - other.birth - epsilon)) 52 | return (birth < other.birth); 53 | 54 | //else 55 | return false; 56 | } 57 | 58 | Barcode::Barcode() 59 | { 60 | } 61 | 62 | //adds a bar to the barcode 63 | void Barcode::add_bar(double b, double d, unsigned m) 64 | { 65 | bars.insert(MultiBar(b, d, m)); 66 | } 67 | 68 | //shifts the barcode by adding amount to each endpoint of each bar 69 | std::unique_ptr Barcode::shift(double amount) 70 | { 71 | std::unique_ptr bc = std::unique_ptr(new Barcode()); 72 | 73 | for (std::multiset::iterator it = bars.begin(); it != bars.end(); ++it) { 74 | MultiBar mb = *it; 75 | bc->add_bar(mb.birth + amount, mb.death + amount, mb.multiplicity); 76 | } 77 | 78 | return bc; 79 | } 80 | 81 | //returns an iterator to the first bar in the barcode 82 | std::set::const_iterator Barcode::begin() const 83 | { 84 | return bars.cbegin(); 85 | } 86 | 87 | //returns an iterator to the pst-the-end element the barcode 88 | std::set::const_iterator Barcode::end() const 89 | { 90 | return bars.cend(); 91 | } 92 | 93 | //returns the number of multibars in the barcode 94 | unsigned Barcode::size() const 95 | { 96 | return bars.size(); 97 | } 98 | 99 | //for testing only 100 | void Barcode::print() const 101 | { 102 | Debug qd = debug(true); 103 | qd << " rescaled barcode: "; 104 | for (std::multiset::iterator it = bars.begin(); it != bars.end(); ++it) { 105 | MultiBar b = *it; 106 | qd << "(" << b.birth << "," << b.death << ")x" << b.multiplicity << ", "; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /dcel/barcode.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef __BARCODE_H__ 22 | #define __BARCODE_H__ 23 | 24 | #include 25 | #include 26 | 27 | struct MultiBar { 28 | double birth; //coordinate where this bar begins 29 | double death; //coordinate where this bar ends 30 | unsigned multiplicity; //multiplicity of this bar 31 | 32 | MultiBar(double b, double d, unsigned m); 33 | MultiBar(const MultiBar& other); 34 | 35 | bool operator<(const MultiBar other) const; 36 | }; 37 | 38 | class Barcode { 39 | public: 40 | Barcode(); 41 | 42 | void add_bar(double b, double d, unsigned m); //adds a bar to the barcode 43 | 44 | std::unique_ptr shift(double amount); //shifts the barcode by adding amount to each endpoint of each bar 45 | 46 | std::multiset::const_iterator begin() const; //returns an iterator to the first bar in the barcode 47 | std::multiset::const_iterator end() const; //returns an iterator to the pst-the-end element the barcode 48 | unsigned size() const; //returns the number of multibars in the barcode 49 | 50 | void print() const; //for testing only 51 | 52 | private: 53 | std::multiset bars; //must be a multiset because the comparison operator for MultiBars might not establish a total order 54 | }; 55 | 56 | #endif // __BARCODE_H__ 57 | -------------------------------------------------------------------------------- /dcel/barcode_template.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef __BARCODE_TEMPLATE_H__ 22 | #define __BARCODE_TEMPLATE_H__ 23 | 24 | #include "barcode.h" 25 | #include "grades.h" 26 | #include "math/template_point.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | struct BarTemplate { 32 | unsigned begin; //index of TemplatePointsMatrixEntry of the equivalence class corresponding to the beginning of this bar 33 | unsigned end; //index of TemplatePointsMatrixEntry of the equivalence class corresponding to the end of this bar 34 | mutable unsigned multiplicity; //maybe this is bad style, but multiplicity is not involved in comparisons 35 | 36 | BarTemplate(unsigned a, unsigned b); 37 | BarTemplate(unsigned a, unsigned b, unsigned m); 38 | BarTemplate(const BarTemplate& other); 39 | BarTemplate(); // for serialization 40 | 41 | bool operator<(const BarTemplate other) const; 42 | 43 | MSGPACK_DEFINE(begin, end, multiplicity); 44 | 45 | friend bool operator==(BarTemplate const& left, BarTemplate const& right); 46 | }; 47 | 48 | class BarcodeTemplate { 49 | public: 50 | BarcodeTemplate(); 51 | 52 | void add_bar(unsigned a, unsigned b); //adds a bar to the barcode template (updating multiplicity, if necessary) 53 | void add_bar(unsigned a, unsigned b, unsigned m); //adds a bar with multiplicity to the barcode template 54 | 55 | std::set::iterator begin(); //returns an iterator to the first bar in the barcode 56 | std::set::iterator end(); //returns an iterator to the past-the-end element of the barcode 57 | bool is_empty(); //returns true iff this barcode has no bars 58 | 59 | //rescales a barcode template by projecting points onto the line specificed by angle and offset 60 | // NOTE: parametrization of the line is as in the RIVET paper 61 | // NOTE: angle in DEGREES 62 | std::unique_ptr rescale(double angle, double offset, 63 | const std::vector& template_points, 64 | const Grades& grades); 65 | 66 | //computes the projection of an xi support point onto the line specificed by angle and offset 67 | // NOTE: parametrization of the line is as in the RIVET paper 68 | // NOTE: returns INFTY if the point has no projection (can happen only for horizontal and vertical lines) 69 | // NOTE: angle in DEGREES 70 | double project(const TemplatePoint& pt, double angle, double offset, const Grades& grades); 71 | 72 | void print(); //for testing only 73 | 74 | MSGPACK_DEFINE(bars); 75 | friend bool operator==(BarcodeTemplate const& left, BarcodeTemplate const& right); 76 | 77 | private: 78 | std::set bars; 79 | }; 80 | 81 | #endif // __BARCODE_TEMPLATE_H__ 82 | -------------------------------------------------------------------------------- /dcel/dcel.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "dcel.h" 22 | 23 | #include "anchor.h" 24 | #include 25 | 26 | #include "debug.h" 27 | 28 | /*** implementation of class Vertex **/ 29 | 30 | Vertex::Vertex(double x_coord, double y_coord) 31 | : incident_edge(nullptr) 32 | , x(x_coord) 33 | , y(y_coord) 34 | { 35 | } 36 | 37 | Vertex::Vertex() 38 | : incident_edge(nullptr) 39 | , x(0) 40 | , y(0) 41 | { 42 | } 43 | 44 | void Vertex::set_incident_edge(Halfedge* edge) 45 | { 46 | incident_edge = edge; 47 | } 48 | 49 | Halfedge* Vertex::get_incident_edge() 50 | { 51 | return incident_edge; 52 | } 53 | 54 | double Vertex::get_x() 55 | { 56 | return x; 57 | } 58 | 59 | double Vertex::get_y() 60 | { 61 | return y; 62 | } 63 | 64 | Debug& operator<<(Debug& qd, const Vertex& v) 65 | { 66 | auto raw = reinterpret_cast(&*(v.incident_edge)); 67 | qd << "(" << v.x << ", " << v.y << ", " << raw << ")"; 68 | return qd; 69 | } 70 | 71 | bool Vertex::operator==(Vertex const& other) 72 | { 73 | return x == other.x && y == other.y; 74 | } 75 | 76 | /*** implementation of class Halfedge ***/ 77 | 78 | Halfedge::Halfedge(Vertex* v, Anchor* p) 79 | : origin(v) 80 | , twin(nullptr) 81 | , next(nullptr) 82 | , prev(nullptr) 83 | , face(nullptr) 84 | , anchor(p) 85 | { 86 | } 87 | 88 | Halfedge::Halfedge() 89 | : origin(nullptr) 90 | , twin(nullptr) 91 | , next(nullptr) 92 | , prev(nullptr) 93 | , face(nullptr) 94 | , anchor(nullptr) 95 | { 96 | } 97 | 98 | void Halfedge::set_twin(Halfedge* e) 99 | { 100 | twin = e; 101 | } 102 | 103 | Halfedge* Halfedge::get_twin() const 104 | { 105 | return twin; 106 | } 107 | 108 | void Halfedge::set_next(Halfedge* e) 109 | { 110 | next = e; 111 | } 112 | 113 | Halfedge* Halfedge::get_next() const 114 | { 115 | return next; 116 | } 117 | 118 | void Halfedge::set_prev(Halfedge* e) 119 | { 120 | prev = e; 121 | } 122 | 123 | Halfedge* Halfedge::get_prev() const 124 | { 125 | return prev; 126 | } 127 | 128 | void Halfedge::set_origin(Vertex* v) 129 | { 130 | origin = v; 131 | } 132 | 133 | Vertex* Halfedge::get_origin() const 134 | { 135 | return origin; 136 | } 137 | 138 | void Halfedge::set_face(Face* f) 139 | { 140 | face = f; 141 | } 142 | 143 | Face* Halfedge::get_face() const 144 | { 145 | return face; 146 | } 147 | 148 | void Halfedge::set_anchor(Anchor* anchor) 149 | { 150 | this->anchor = anchor; 151 | } 152 | 153 | Anchor* Halfedge::get_anchor() const 154 | { 155 | return anchor; 156 | } 157 | 158 | Debug& operator<<(Debug& qd, const Halfedge& e) 159 | { 160 | Halfedge* t = e.twin; 161 | qd << *(e.origin) << "--" << *(t->origin) << "; "; 162 | if (e.anchor == nullptr) 163 | qd << "Anchor null; "; 164 | else 165 | qd << "Anchor coords (" << e.anchor->get_x() << ", " << e.anchor->get_y() << "); "; 166 | return qd; 167 | } 168 | 169 | /*** implementation of class Face ***/ 170 | 171 | Face::Face(Halfedge* e, unsigned long id) 172 | : boundary(e) 173 | , visited(false) 174 | , identifier(id) 175 | { 176 | } 177 | 178 | Face::Face() 179 | : boundary() 180 | , visited(false) 181 | , identifier(-1) 182 | { 183 | } 184 | 185 | Face::~Face() 186 | { 187 | } 188 | 189 | void Face::set_boundary(Halfedge* e) 190 | { 191 | boundary = e; 192 | } 193 | 194 | Halfedge* Face::get_boundary() 195 | { 196 | return boundary; 197 | } 198 | 199 | BarcodeTemplate& Face::get_barcode() 200 | { 201 | return dbc; 202 | } 203 | 204 | void Face::set_barcode(const BarcodeTemplate& bt) 205 | { 206 | dbc = bt; ///TODO: is this good design??? 207 | } 208 | 209 | bool Face::has_been_visited() 210 | { 211 | return visited; 212 | } 213 | 214 | void Face::mark_as_visited() 215 | { 216 | visited = true; 217 | } 218 | 219 | Debug& operator<<(Debug& qd, const Face& f) 220 | { 221 | Halfedge* start = f.boundary; 222 | Halfedge* curr = start; 223 | do { 224 | qd << *(curr->get_origin()) << "--"; 225 | curr = curr->get_next(); 226 | } while (curr != start); 227 | qd << "cycle; "; 228 | return qd; 229 | } 230 | 231 | unsigned long Face::id() const 232 | { 233 | return this->identifier; 234 | } 235 | 236 | bool operator==(TemplatePointsMessage const& left, TemplatePointsMessage const& right) 237 | { 238 | bool support = left.template_points == right.template_points; 239 | bool hom = left.homology_dimensions == right.homology_dimensions; 240 | bool x = left.x_exact == right.x_exact; 241 | bool y = left.y_exact == right.y_exact; 242 | return support & hom & x & y; 243 | } 244 | -------------------------------------------------------------------------------- /dcel/grades.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by bkeller on 11/22/16. 23 | // 24 | 25 | #include "grades.h" 26 | 27 | Grades::Grades() 28 | : x() 29 | , y() 30 | { 31 | } 32 | 33 | Grades::Grades(std::vector x, std::vector y) 34 | : x(rivet::numeric::to_doubles(x)) 35 | , y(rivet::numeric::to_doubles(y)) 36 | { 37 | } 38 | 39 | double Grades::min_offset() const 40 | { 41 | if (x.empty() || y.empty()) { 42 | return 0; 43 | } 44 | return std::min(-1 * x.back(), y.front()); 45 | } 46 | 47 | double Grades::max_offset() const 48 | { 49 | if (x.empty() || y.empty()) { 50 | return 0; 51 | } 52 | return std::max(y.back(), -1 * x.front()); 53 | } 54 | -------------------------------------------------------------------------------- /dcel/grades.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Bryn Keller on 11/22/16. 23 | // 24 | 25 | #ifndef RIVET_CONSOLE_GRADES_H 26 | #define RIVET_CONSOLE_GRADES_H 27 | 28 | #include 29 | #include 30 | 31 | struct Grades { 32 | std::vector x; 33 | std::vector y; 34 | 35 | Grades(); 36 | 37 | Grades(std::vector x, std::vector y); 38 | 39 | double min_offset() const; 40 | double max_offset() const; 41 | }; 42 | 43 | #endif //RIVET_CONSOLE_GRADES_H 44 | -------------------------------------------------------------------------------- /debug.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Bryn Keller on 5/23/16. 23 | // 24 | #include "debug.h" 25 | 26 | #ifdef QT_CORE_LIB 27 | 28 | Debug debug(bool nospace) 29 | { 30 | auto qd = qDebug(); 31 | if (nospace) { 32 | qd = qd.nospace(); 33 | } 34 | return qd; 35 | } 36 | 37 | #else 38 | 39 | Debug debug(bool nospace, std::ostream& out) 40 | { 41 | return Debug(out, !nospace); 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /debug.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef RIVET_DEBUG_H 22 | #define RIVET_DEBUG_H 23 | 24 | #include 25 | #include 26 | 27 | #ifdef QT_CORE_LIB 28 | 29 | #include 30 | using Debug = QDebug; 31 | 32 | Debug debug(bool nospace = false); 33 | 34 | #else 35 | 36 | struct Debug { 37 | std::ostream& os; 38 | bool space; 39 | bool alive; 40 | 41 | Debug(std::ostream& os = std::clog, bool space = true) 42 | : os(os) 43 | , space(space) 44 | , alive(true) 45 | { 46 | } 47 | Debug(Debug&& rhs) 48 | : os(rhs.os) 49 | , space(rhs.space) 50 | , alive(true) 51 | { 52 | rhs.alive = false; 53 | } 54 | Debug(Debug& rhs) 55 | : os(rhs.os) 56 | , space(rhs.space) 57 | , alive(true) 58 | { 59 | rhs.alive = false; 60 | } 61 | ~Debug() 62 | { 63 | if (alive && space) 64 | os << std::endl; 65 | } 66 | }; 67 | 68 | template 69 | Debug operator<<(Debug&& d, T const& x) 70 | { 71 | (d.os) << x; 72 | if (d.space) 73 | d.os << " "; 74 | return std::move(d); 75 | } 76 | 77 | template 78 | Debug operator<<(Debug& d, T const& x) 79 | { 80 | d.os << x; 81 | if (d.space) 82 | d.os << " "; 83 | return std::move(d); 84 | } 85 | 86 | Debug debug(bool nospace = false, std::ostream& out = std::clog); 87 | 88 | #endif 89 | #endif 90 | -------------------------------------------------------------------------------- /docs/_static/custom.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | //make all external links open in new windows/tabs 3 | $.expr[':'].external = function(obj){ 4 | return !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname) && !obj.href.match(/^javascript\:/) && !obj.href.match(/^$/); 5 | }; 6 | $('a:external').attr('target', '_blank').attr('rel', 'noopener'); 7 | }); -------------------------------------------------------------------------------- /docs/images/RIVET_progress_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/RIVET_progress_box.png -------------------------------------------------------------------------------- /docs/images/RIVET_screenshot_circle300.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/RIVET_screenshot_circle300.png -------------------------------------------------------------------------------- /docs/images/RIVET_screenshot_circle300_balldensity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/RIVET_screenshot_circle300_balldensity.png -------------------------------------------------------------------------------- /docs/images/RIVET_screenshot_circle300v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/RIVET_screenshot_circle300v.png -------------------------------------------------------------------------------- /docs/images/circle300_point_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/circle300_point_plot.png -------------------------------------------------------------------------------- /docs/images/file_input_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/file_input_dialog.png -------------------------------------------------------------------------------- /docs/images/file_input_selections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/file_input_selections.png -------------------------------------------------------------------------------- /docs/images/flowchart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/flowchart.pdf -------------------------------------------------------------------------------- /docs/images/flowchart.tex: -------------------------------------------------------------------------------- 1 | %% 2 | %% TO BUILD A PDF FILE: uncomment the following line, comment the SVG line below, and run "pdflatex flowchart.tex" 3 | %% 4 | \documentclass[crop,tikz]{standalone} 5 | 6 | %% 7 | %% TO BUILD A SVG FILE: comment the PDF line above, uncomment the line following line, and run "pdflatex -shell-escape flowchart.tex" 8 | %% 9 | %\documentclass[crop,tikz,convert={outfile=\jobname.svg}]{standalone} 10 | 11 | \pagestyle{empty} 12 | \usepackage[utf8]{inputenc} 13 | \usepackage{tikz} 14 | 15 | \usetikzlibrary{shapes.geometric, arrows} 16 | 17 | \tikzstyle{box} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, thick, fill=green!30] 18 | \tikzstyle{redBox} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, thick, fill=red!30] 19 | \tikzstyle{yellowBox} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, thick, fill=yellow!30] 20 | \tikzstyle{yellowBoxRedBorder} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=red, thick, fill=yellow!30] 21 | \tikzstyle{plainBox} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, thick] 22 | \tikzstyle{plainBoxRedBorder} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=red,thick] 23 | 24 | \tikzstyle{dataBox} = [rectangle, rounded corners, minimum width=9.0cm, minimum height=4.9cm,text centered, draw=black,thick, fill=gray!10] 25 | \tikzstyle{invariantBox} = [rectangle, rounded corners, minimum width=5.5cm, minimum height=6.9cm,text centered, draw=black,thick, fill=blue!10] 26 | 27 | \tikzstyle{arrow} = [thick,->,>=stealth] 28 | 29 | \begin{document} 30 | \begin{tikzpicture}[node distance=1.9cm] 31 | 32 | \node (data) [dataBox,yshift=-2.1cm,xshift=-.3cm] {}; 33 | \node (dataLabel)[xshift=.2cm] {\textbf{Data}}; 34 | 35 | \node (pointsAnchor) [yshift = -1cm] {}; 36 | \node (metricAnchor) [below of= pointsAnchor] {}; 37 | \node (pointsFun) [box,left of=pointsAnchor,xshift=-.5cm] {Point Cloud w/ Function}; 38 | \node (points) [box,right of=pointsAnchor,xshift=.5cm] {Point Cloud}; 39 | \node (metricFun) [box,left of=metricAnchor,xshift=-.5cm,yshift=-.8cm] {Metric Space w/ Function}; 40 | \node (metric) [box,right of=metricAnchor,xshift=.5cm,yshift=-.8cm] {Metric Space}; 41 | 42 | \node (bifiltration) [box, below of=metricAnchor,yshift=-1.6cm] {Bifiltration}; 43 | %\node (input) [yellowBox,left of= bifiltration, xshift=-5cm] {Text File Input}; 44 | 45 | \node (firep) [box, below of=bifiltration,yshift=-.8cm] {FIRep (short chain complex of free modules)}; 46 | 47 | \node (magicAnchor) [below of= firep,yshift=-.8cm] {}; 48 | \node (minpres) [yellowBox, left of=magicAnchor,xshift=-1.2cm] {Minimal Presentation}; 49 | 50 | \node (invariant) [invariantBox,right of= magicAnchor,xshift=1.2cm,yshift=-2.5cm] {}; 51 | \node (invariantLabel) [below of=invariant,yshift=-1.1cm] {\textbf{Invariants RIVET Visualizes}}; 52 | \node (hilbert)[yellowBoxRedBorder, right of= magicAnchor,xshift=1.2cm]{Hilbert Function}; 53 | 54 | \node (bettiCombine) [coordinate,below of= hilbert,yshift=.8cm] {}; 55 | \node (betti) [yellowBoxRedBorder, below of= bettiCombine,yshift=.8cm]{Bigraded Betti Numbers}; 56 | \node (arrangement)[plainBoxRedBorder, below of= minpres,yshift=-.31cm] {Augmented Arrangement}; 57 | \node (barcodes)[yellowBox, below of= betti, yshift=-.4cm] {Barcodes of 1-D slices}; 58 | %\node (visualization)[plainBox, below of= barcodes,yshift=-1cm] {Visualization}; 59 | %\node (minpres) [box, below of=firep, yshift=-0.5cm] {Minimal Presentation}; 60 | %\node (pro2a) [process, below of=minpres, yshift=-0.5cm] {}; 61 | %\node (pro2b) [process, right of=minpres, xshift=2cm] {Process 2b}; 62 | %\node (out1) [io, below of=pro2a] {Output}; 63 | %\node (stop) [box, below of=out1] {Stop}; 64 | %\draw [arrow] (input) -- (data); 65 | %\draw [arrow] (input) -- (bifiltration); 66 | %\draw [arrow] (input) -- (firep); 67 | \draw [arrow] (points) -- node[anchor=east,xshift=-0.7cm]{Euclidean distance} (metric); 68 | \draw [arrow] (pointsFun) -- (metricFun); 69 | \draw [arrow] (metric) -- node[anchor=west,yshift=-.1cm]{degree-Rips}(bifiltration); 70 | \draw [arrow] (metricFun) -- node[anchor=east,yshift=-.1cm]{function-Rips} (bifiltration); 71 | \draw [arrow] (bifiltration) -- node[anchor=west]{simplicial chains; trick of Chacholski et al.} (firep); 72 | \draw [arrow] (firep) -- node[anchor=west,xshift=.2cm,yshift=.05cm]{sparse lin. alg.} (minpres); 73 | \draw [arrow] (firep) -- (hilbert); 74 | \draw [thick] (minpres) -- (bettiCombine); 75 | \draw [thick] (hilbert) -- (bettiCombine); 76 | \draw [arrow] (bettiCombine) -- (betti); 77 | %\draw [thick] (betti) -- node[anchor=west,xshift=-1.7cm,yshift=.4cm]{line arrangement}(arrangementCombine); 78 | \draw [arrow] (minpres) -- (arrangement); 79 | %\draw [arrow] (invariant) -- (visualization); 80 | %\draw [arrow] (minpres) -- node[anchor=east] {yes} (pro2a); 81 | %\draw [arrow] (minpres) -- node[anchor=south] {no} (pro2b); 82 | %\draw [arrow] (pro2b) |- (firep); 83 | %\draw [arrow] (pro2a) -- (out1); 84 | %\draw [arrow] (out1) -- (stop); 85 | 86 | \draw [arrow] (arrangement) -- node[anchor=east,xshift=.1cm,yshift=-.3cm]{fast queries} (barcodes); 87 | \end{tikzpicture} 88 | 89 | \end{document} -------------------------------------------------------------------------------- /docs/images/line_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivetTDA/rivet/32ce9e80b06353ed24f1e4e24469bdc6968cc52f/docs/images/line_diagram.png -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. RIVET documentation master file, created by 2 | sphinx-quickstart on Wed Jul 4 17:46:37 2018. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | RIVET Documentation 7 | =================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Contents: 12 | :numbered: 13 | 14 | about 15 | installing 16 | preliminaries 17 | pipeline 18 | gettingstarted 19 | rivetconsole 20 | visualization 21 | inputdata 22 | old_inputdata 23 | 24 | 25 | Indices and tables 26 | ================== 27 | 28 | * :ref:`genindex` 29 | * :ref:`search` 30 | -------------------------------------------------------------------------------- /docs/pipeline.rst: -------------------------------------------------------------------------------- 1 | .. include:: 2 | .. _structure: 3 | 4 | Computation Pipeline 5 | ==================================== 6 | The following figure illustrates RIVET’s pipeline for working with the 2-parameter persistent homology of data. 7 | 8 | .. figure:: images/flowchart.* 9 | :width: 400px 10 | :align: center 11 | :height: 600px 12 | :figclass: align-center 13 | 14 | The RIVET pipeline. Green items can be input directly to RIVET via a file. Yellow items can be printed to the console. Items with red boundary can be saved in a *module invariants file*, which serves as input to RIVET’s visualization. 15 | 16 | 17 | We now explain this pipeline: 18 | 19 | RIVET can accept as input a data set, a bifiltration, or an FIRep. RIVET always works with a single homology degree at a time; when giving data or a bifiltration as input, one specifies the degree of homology to consider. 20 | 21 | RIVET accepts data in the form of either a point cloud in :math:`\mathbb R^n`, or a finite metric space (represented as distance matrix). Optionally, a function on the points can also be given by the user or precomputed by RIVET. If a function is specified, then RIVET computes a function-Rips bifiltration. If no function is specified, then RIVET computes the degree-Rips bifiltration. 22 | 23 | Given a bifiltration :math:`F`, RIVET constructs an FIRep for :math:`H_j(F)` in the specified degree :math:`j`. If :math:`F` is multi-critical, RIVET uses the trick of Chacholski et al. LINK to obtain the FIRep. 24 | 25 | Given an FIRep, RIVET computes a minimal presentation of its homology module. This computation also yields the Hilbert function of the module with almost no extra work. The 0th and 1st bigraded Betti numbers of a bipersistence module :math:`M` can be read directly off of the minimal presentation. Given these and the Hilbert function, a simple formula yields the 2nd bigraded Betti numbers as well. 26 | 27 | RIVET uses the minimal presentation of :math:`M` to compute the *augmented arrangement* of :math:`M`. This is a line arrangement in the right half plane, together with a barcode at each face of the line arrangement. The augmented arrangement is used to perform fast queries of the fibered barcode of :math:`M`. 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /interface/aboutmessagebox.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "aboutmessagebox.h" 22 | #include "ui_aboutmessagebox.h" 23 | 24 | AboutMessageBox::AboutMessageBox(QWidget* parent) 25 | : QDialog(parent) 26 | , ui(new Ui::AboutMessageBox) 27 | { 28 | ui->setupUi(this); 29 | 30 | ui->codeURL->setTextInteractionFlags(Qt::LinksAccessibleByMouse); 31 | ui->codeURL->setOpenExternalLinks(true); 32 | ui->codeURL->setTextFormat(Qt::RichText); 33 | ui->codeURL->setText("https://github.com/rivetTDA/rivet/"); 34 | 35 | ui->docURL->setTextInteractionFlags(Qt::LinksAccessibleByMouse); 36 | ui->docURL->setOpenExternalLinks(true); 37 | ui->docURL->setTextFormat(Qt::RichText); 38 | ui->docURL->setText("https://rivet.readthedocs.io/"); 39 | } 40 | 41 | AboutMessageBox::~AboutMessageBox() 42 | { 43 | delete ui; 44 | } 45 | 46 | void AboutMessageBox::on_pushButton_clicked() 47 | { 48 | close(); 49 | } 50 | -------------------------------------------------------------------------------- /interface/aboutmessagebox.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef ABOUTMESSAGEBOX_H 22 | #define ABOUTMESSAGEBOX_H 23 | 24 | #include 25 | 26 | namespace Ui { 27 | class AboutMessageBox; 28 | } 29 | 30 | class AboutMessageBox : public QDialog { 31 | Q_OBJECT 32 | 33 | public: 34 | explicit AboutMessageBox(QWidget* parent = 0); 35 | ~AboutMessageBox(); 36 | 37 | private slots: 38 | void on_pushButton_clicked(); 39 | 40 | private: 41 | Ui::AboutMessageBox* ui; 42 | }; 43 | 44 | #endif // ABOUTMESSAGEBOX_H 45 | -------------------------------------------------------------------------------- /interface/aboutmessagebox.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | AboutMessageBox 4 | 5 | 6 | 7 | 0 8 | 0 9 | 430 10 | 370 11 | 12 | 13 | 14 | About RIVET 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 10 23 | 10 24 | 81 25 | 20 26 | 27 | 28 | 29 | 30 | 18 31 | 75 32 | true 33 | 34 | 35 | 36 | RIVET 37 | 38 | 39 | 40 | 41 | 42 | 110 43 | 40 44 | 281 45 | 20 46 | 47 | 48 | 49 | https://github.com/rivetTDA/rivet/ 50 | 51 | 52 | 53 | 54 | 55 | 10 56 | 70 57 | 121 58 | 20 59 | 60 | 61 | 62 | Documentation: 63 | 64 | 65 | 66 | 67 | 68 | 10 69 | 100 70 | 410 71 | 91 72 | 73 | 74 | 75 | RIVET is made available under the under the terms of the GNU General Public License. The software is provided “as is,” without warranty of any kind, even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for details. 76 | 77 | 78 | true 79 | 80 | 81 | 82 | 83 | 84 | 165 85 | 330 86 | 100 87 | 27 88 | 89 | 90 | 91 | Close 92 | 93 | 94 | 95 | 96 | 97 | 10 98 | 200 99 | 410 100 | 111 101 | 102 | 103 | 104 | Development of RIVET has been supported in part by the National Science Foundation under grant DMS-1606967. Additional support has been been provided by the Institute for Mathematics and its Applications, Columbia University, Princeton Neuroscience Institute, St. Olaf College, and the NIH (grant U54-CA193313-01). 105 | 106 | 107 | true 108 | 109 | 110 | 111 | 112 | 113 | 10 114 | 40 115 | 111 116 | 20 117 | 118 | 119 | 120 | Source code: 121 | 122 | 123 | 124 | 125 | 126 | 130 127 | 70 128 | 240 129 | 20 130 | 131 | 132 | 133 | https://rivet.readthedocs.io/ 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /interface/c_api.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Bryn Keller on 11/16/17. 3 | // 4 | 5 | #ifndef RIVET_CONSOLE_C_API_H 6 | #define RIVET_CONSOLE_C_API_H 7 | 8 | #include 9 | 10 | extern "C" { 11 | 12 | //typedef struct { 13 | // unsigned dimensions; 14 | // double max_distance; 15 | // double * data; 16 | // char * param1_name; 17 | // char * param2_name; 18 | //} PointCloud; 19 | // 20 | 21 | typedef struct { 22 | void* input_params; 23 | void* template_points; 24 | void* arrangement; 25 | } Computed; 26 | 27 | typedef struct { 28 | double birth; 29 | double death; 30 | unsigned multiplicity; 31 | } Bar; 32 | 33 | typedef struct { 34 | Bar* bars; 35 | size_t length; 36 | double angle; 37 | double offset; 38 | } BarCode; 39 | 40 | typedef struct { 41 | BarCode* barcodes; 42 | size_t length; 43 | char* error; 44 | size_t error_length; 45 | } BarCodesResult; 46 | 47 | typedef struct { 48 | double x_low; 49 | double y_low; 50 | double x_high; 51 | double y_high; 52 | } ArrangementBounds; 53 | 54 | struct rivet_comp; 55 | typedef rivet_comp RivetComputation; 56 | 57 | typedef struct { 58 | RivetComputation* computation; 59 | char* error; 60 | size_t error_length; 61 | } RivetComputationResult; 62 | 63 | RivetComputationResult read_rivet_computation(const char* bytes, size_t length); 64 | 65 | //Computed* compute_arrangement_from_point_cloud(PointCloud); 66 | BarCodesResult barcodes_from_computation(RivetComputation* rivet_computation, 67 | double* offsets, 68 | double* angles, 69 | size_t query_length); 70 | 71 | ArrangementBounds bounds_from_computation(RivetComputation* rivet_computation); 72 | 73 | void free_rivet_computation_result(RivetComputationResult rivet_computation); 74 | 75 | void free_barcodes_result(BarCodesResult result); 76 | 77 | typedef struct { 78 | int64_t nom; 79 | int64_t denom; 80 | } Ratio; 81 | 82 | typedef struct { 83 | Ratio* x_grades; 84 | size_t x_length; 85 | Ratio* y_grades; 86 | size_t y_length; 87 | } ExactGrades; 88 | 89 | typedef struct { 90 | unsigned x; 91 | unsigned y; 92 | unsigned betti_0; 93 | unsigned betti_1; 94 | unsigned betti_2; 95 | } StructurePoint; 96 | 97 | typedef struct { 98 | ExactGrades* grades; 99 | StructurePoint* points; 100 | size_t length; 101 | } StructurePoints; 102 | 103 | StructurePoints* structure_from_computation(RivetComputation* rivet_computation); 104 | 105 | void free_structure_points(StructurePoints* points); 106 | } 107 | 108 | #endif //RIVET_CONSOLE_C_API_H 109 | -------------------------------------------------------------------------------- /interface/config_parameters.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "config_parameters.h" 22 | 23 | //default values are set here 24 | ConfigParameters::ConfigParameters() 25 | : xi0color(0, 255, 0, 100) //green semi-transparent, for xi_0 support dots 26 | , xi1color(255, 0, 0, 100) //red semi-transparent, for xi_1 support dots 27 | , xi2color(255, 255, 0, 100) //yellow semi-transparent, for xi_2 support dots 28 | , persistenceColor(160, 0, 200, 127) //purple semi-transparent, for persistence bars and dots 29 | , persistenceHighlightColor(255, 140, 0, 150) //orange semi-transparent, for highlighting part of the slice line 30 | , sliceLineColor(0, 0, 255, 150) //blue semi-transparent, for slice line 31 | , sliceLineHighlightColor(0, 200, 200, 150) //cyan semi-transparent, for highlighting the slice line on click-and-drag 32 | , bettiDotRadius(5) //radius of dot representing xi_0 = 1 or xi_1 = 1 33 | , persistenceDotRadius(5) //radius of dot representing one homology class in persistence diagram 34 | , autoDotSize(true) //automatic dot sizing is initially on 35 | , sliceLineWidth(5) //width of selected line (pixels) 36 | , persistenceBarWidth(4) //width of persistence bars (pixels) 37 | , persistenceBarSpace(5) //space between persistence bars(pixels) 38 | , diagramFont() //system default font 39 | { 40 | diagramFont.setPointSize(12); // SET DEFAULT FONT SIZE HERE 41 | } 42 | -------------------------------------------------------------------------------- /interface/config_parameters.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef CONFIG_PARAMETERS_H 22 | #define CONFIG_PARAMETERS_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | //these parameters control the visualization and are (mostly) user-customizable through the Configure dialog box 29 | struct ConfigParameters { 30 | //colors 31 | QColor xi0color; 32 | QColor xi1color; 33 | QColor xi2color; 34 | QColor persistenceColor; 35 | QColor persistenceHighlightColor; 36 | QColor sliceLineColor; 37 | QColor sliceLineHighlightColor; 38 | 39 | //sizes 40 | int bettiDotRadius; 41 | int persistenceDotRadius; 42 | bool autoDotSize; 43 | int sliceLineWidth; 44 | int persistenceBarWidth; 45 | int persistenceBarSpace; 46 | 47 | //text 48 | QString xLabel; 49 | QString yLabel; 50 | 51 | //fonts 52 | QFont diagramFont; 53 | 54 | //constructor 55 | ConfigParameters(); 56 | }; 57 | 58 | #endif // CONFIG_PARAMETERS_H 59 | -------------------------------------------------------------------------------- /interface/configuredialog.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef CONFIGUREDIALOG_H 22 | #define CONFIGUREDIALOG_H 23 | 24 | struct ConfigParameters; 25 | 26 | #include "api.h" 27 | #include "input_parameters.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace Ui { 35 | class ConfigureDialog; 36 | } 37 | 38 | class ConfigureDialog : public QDialog { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit ConfigureDialog(ConfigParameters& c_params, InputParameters& i_params, QWidget* parent = 0); 43 | ~ConfigureDialog(); 44 | void closeEvent(QCloseEvent* event); 45 | 46 | signals: 47 | void window_closed(); 48 | 49 | private slots: 50 | void on_cancelButton_clicked(); 51 | void on_okButton_clicked(); 52 | 53 | void on_xi0colorButton_clicked(); 54 | void on_xi1colorButton_clicked(); 55 | void on_xi2colorButton_clicked(); 56 | void on_persistenceColorButton_clicked(); 57 | void on_persistenceHighlightColorButton_clicked(); 58 | void on_lineColorButton_clicked(); 59 | void on_lineHighlightColorButton_clicked(); 60 | 61 | void on_xi0spinBox_valueChanged(int arg1); 62 | void on_xi1spinBox_valueChanged(int arg1); 63 | void on_xi2spinBox_valueChanged(int arg1); 64 | void on_persistenceSpinBox_valueChanged(int arg1); 65 | void on_persistenceHighlightSpinBox_valueChanged(int arg1); 66 | void on_lineSpinBox_valueChanged(int arg1); 67 | void on_lineHighlightSpinBox_valueChanged(int arg1); 68 | 69 | void on_defaultColorsButton_clicked(); 70 | 71 | void on_bettiDotSpinBox_valueChanged(int arg1); 72 | void on_persistenceDotSpinBox_valueChanged(int arg1); 73 | 74 | void on_AutoDotSizeCheckBox_clicked(bool checked); 75 | 76 | void on_fontSizeSpinBox_valueChanged(int arg1); 77 | 78 | private: 79 | Ui::ConfigureDialog* ui; 80 | ConfigParameters& config_params; 81 | InputParameters& input_params; 82 | 83 | //data structures to store selected configuration until user clicks the OK button 84 | QColor xi0col; 85 | QColor xi1col; 86 | QColor xi2col; 87 | QColor perCol; 88 | QColor perHiCol; 89 | QColor lineCol; 90 | QColor lineHiCol; 91 | int bettiRadius; 92 | int perRadius; 93 | bool autoDots; 94 | QFont dgmFont; 95 | }; 96 | 97 | #endif // CONFIGUREDIALOG_H 98 | -------------------------------------------------------------------------------- /interface/console_interaction.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Bryn Keller on 7/7/16. 23 | // 24 | 25 | #include "console_interaction.h" 26 | 27 | QString RivetConsoleApp::errorMessage(QProcess::ProcessError error) 28 | { 29 | 30 | switch (error) { 31 | case QProcess::FailedToStart: 32 | return ("Error launching rivet_console"); 33 | case QProcess::Crashed: 34 | return ("Rivet console crashed"); 35 | case QProcess::Timedout: 36 | return ("Rivet console timed out"); 37 | case QProcess::WriteError: 38 | return ("Couldn't write to rivet console"); 39 | case QProcess::ReadError: 40 | return ("Couldn't read from Rivet console"); 41 | default: 42 | return ("Error communicating with Rivet console"); 43 | } 44 | } 45 | 46 | std::unique_ptr RivetConsoleApp::start(QStringList args) 47 | { 48 | std::unique_ptr console(new QProcess()); 49 | console->setProcessChannelMode(QProcess::MergedChannels); 50 | console->setWorkingDirectory(QCoreApplication::applicationDirPath()); 51 | console->start("./rivet_console", args); 52 | return console; 53 | } 54 | -------------------------------------------------------------------------------- /interface/console_interaction.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Bryn Keller on 7/7/16. 23 | // 24 | 25 | #ifndef RIVET_CONSOLE_CONSOLE_INTERACTION_H 26 | #define RIVET_CONSOLE_CONSOLE_INTERACTION_H 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class RivetConsoleApp { 33 | public: 34 | static QString errorMessage(QProcess::ProcessError error); 35 | static std::unique_ptr start(QStringList args); 36 | }; 37 | 38 | #endif //RIVET_CONSOLE_CONSOLE_INTERACTION_H 39 | -------------------------------------------------------------------------------- /interface/control_dot.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Matthew L. Wright, 2014 23 | // 24 | 25 | #ifndef CONTROL_DOT_H 26 | #define CONTROL_DOT_H 27 | 28 | struct ConfigParameters; 29 | class SliceLine; 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | class ControlDot : public QGraphicsItem { 37 | public: 38 | ControlDot(SliceLine* line, bool left_bottom, ConfigParameters* params); 39 | 40 | QRectF boundingRect() const; 41 | void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*); 42 | QVariant itemChange(GraphicsItemChange change, const QVariant& value); 43 | void set_position(const QPointF& newpos); 44 | //should these next two be private/protected? 45 | ControlDot* other; //the other dot 46 | bool position_lock; //prevents errant motion; is true whenever the other dot is being moved 47 | 48 | protected: 49 | void mousePressEvent(QGraphicsSceneMouseEvent* event); 50 | void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); 51 | 52 | private: 53 | SliceLine* slice_line; 54 | ConfigParameters* config_params; 55 | 56 | bool pressed; 57 | bool left_bottom; //TRUE if this is a left-bottom control dot, FALSE if this is a right-top control dot 58 | bool update_lock; //TRUE when the dot is being moved as result of external input; to avoid update loops 59 | }; 60 | 61 | #endif // CONTROL_DOT_H 62 | -------------------------------------------------------------------------------- /interface/file_input_reader.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "file_input_reader.h" 22 | #include 23 | 24 | #include 25 | 26 | FileInputReader::FileInputReader(std::ifstream& file) 27 | : in(file) 28 | , line_number(0) 29 | , next_line_found(false) 30 | { 31 | find_next_line(0); 32 | } 33 | 34 | // if it starts with -- or - or , it is a flag 35 | bool FileInputReader::is_flag(std::string str) 36 | { 37 | // use ASCII values to check if digit or not 38 | int first = (char)str[0]; 39 | int second = (char)str[1]; 40 | 41 | if (first == 45 && second == 45) 42 | return true; 43 | if (first == 45 && (second < 48 || second > 57)) 44 | return true; 45 | if (first != 45 && (first < 48 || first > 57)) 46 | return true; 47 | 48 | return false; 49 | } 50 | 51 | //finds the next line in the file that is not empty and not a comment, if such line exists 52 | //this is the only function that should call in.readLine() 53 | void FileInputReader::find_next_line(int old) 54 | { 55 | std::string line; 56 | while (std::getline(in, line)) { 57 | line_number++; 58 | boost::trim(line); 59 | if (line.empty() || line[0] == '#') 60 | continue; 61 | next_line_tokens.clear(); 62 | // old = 1 means old file format, so split by space 63 | if (old || line.find(",") == std::string::npos || is_flag(line)) { 64 | boost::split(next_line_tokens, line, boost::is_space(std::locale()), boost::token_compress_on); 65 | } 66 | // if a "," is there in the line, split by "," 67 | else { 68 | boost::split(next_line_tokens, line, boost::is_any_of(", \t"), boost::token_compress_on); 69 | } 70 | next_line_found = true; 71 | break; 72 | } 73 | } 74 | 75 | //indicates whether another line can be returned 76 | bool FileInputReader::has_next_line() 77 | { 78 | return next_line_found; 79 | } 80 | 81 | //returns the next line as a std::vector of tokens 82 | std::pair, unsigned> FileInputReader::next_line(int old) 83 | { 84 | std::vector current = next_line_tokens; 85 | auto num = line_number; 86 | next_line_found = false; 87 | find_next_line(old); 88 | 89 | return std::make_pair(current, num); 90 | } 91 | -------------------------------------------------------------------------------- /interface/file_input_reader.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | /** 21 | * \brief Reads a file, ignoring white space and comments. returns tokens by line or individually. 22 | * \author Matthew L. Wright 23 | * \date 2015 24 | */ 25 | 26 | #ifndef FILEINPUTREADER_H 27 | #define FILEINPUTREADER_H 28 | 29 | #include 30 | #include 31 | 32 | class FileInputReader : public std::iterator, 34 | std::ptrdiff_t, 35 | std::vector*, 36 | std::vector&> { 37 | public: 38 | FileInputReader(std::ifstream& file); //constructor 39 | 40 | //true iff the file has another line of printable, non-commented characters 41 | bool has_next_line(); 42 | //returns the next line, as a vector of strings, plus the line number at which the line was found 43 | std::pair, unsigned> next_line(int = 1); 44 | 45 | private: 46 | std::ifstream& in; 47 | unsigned line_number; 48 | bool next_line_found; 49 | std::vector next_line_tokens; 50 | void find_next_line(int); 51 | 52 | bool is_flag(std::string str); 53 | }; 54 | 55 | #endif // FILEINPUTREADER_H 56 | -------------------------------------------------------------------------------- /interface/file_writer.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "file_writer.h" 22 | 23 | #include "../dcel/barcode_template.h" 24 | #include "data_reader.h" 25 | #include "input_manager.h" 26 | 27 | #include 28 | 29 | FileWriter::FileWriter(InputParameters& ip, InputData& data, Arrangement& m, std::vector& points) 30 | : input_data(data) 31 | , input_params(ip) 32 | , arrangement(m) 33 | , template_points(points) 34 | { 35 | } 36 | 37 | void FileWriter::write_augmented_arrangement(std::ofstream& stream) 38 | { 39 | 40 | auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); 41 | //At some point just doing stream << std::ctime(&now) started giving ambiguous operator<< errors, 42 | //so let's be explicit. 43 | std::string now_as_string = std::ctime(&now); 44 | //write header info, in comment form 45 | stream << "# augmented arrangement data" << std::endl; 46 | stream << "# computed by RIVET from the input file " << input_params.fileName << std::endl; 47 | stream << "# homology dimension: " << input_params.hom_degree << std::endl; 48 | stream << "# bins: " << input_params.x_bins << " " << input_params.y_bins << std::endl; 49 | stream << "# file created at: " 50 | << now_as_string 51 | << std::endl; 52 | 53 | //write parameters 54 | stream << "RIVET_0" << std::endl; 55 | stream << input_params.hom_degree << std::endl; 56 | stream << input_data.x_label << std::endl; 57 | stream << input_data.y_label << std::endl 58 | << std::endl; 59 | write_grades(stream, arrangement.x_exact, arrangement.y_exact); 60 | 61 | //write values of the multigraded Betti numbers 62 | stream << "xi values" << std::endl; 63 | for (std::vector::iterator it = template_points.begin(); it != template_points.end(); ++it) { 64 | TemplatePoint p = *it; 65 | if (p.zero > 0 || p.one > 0 || p.two > 0) //necessary because the vector template_points also stores anchors (template points) that are not xi support points 66 | stream << p.x << " " << p.y << " " << p.zero << " " << p.one << " " << p.two << std::endl; 67 | } 68 | stream << std::endl; 69 | 70 | //write barcode templates 71 | stream << "barcode templates" << std::endl; 72 | for (unsigned i = 0; i < arrangement.num_faces(); i++) { 73 | BarcodeTemplate& bc = arrangement.get_barcode_template(i); 74 | if (bc.is_empty()) { 75 | stream << "-"; //this denotes an empty barcode (necessary because FileInputReader ignores white space) 76 | } else { 77 | for (std::set::iterator it = bc.begin(); it != bc.end(); ++it) { 78 | stream << it->begin << ","; 79 | if (it->end == (unsigned)-1) //then the bar ends at infinity, but we just write "i" 80 | stream << "i"; 81 | else 82 | stream << it->end; 83 | stream << "," << it->multiplicity << " "; 84 | } 85 | } 86 | stream << std::endl; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /interface/file_writer.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | /** 22 | * \brief Saves an augmented arrangement to a file. 23 | * \author Matthew L. Wright 24 | * \date 2016 25 | */ 26 | 27 | #ifndef FILEWRITER_H 28 | #define FILEWRITER_H 29 | 30 | #include "data_reader.h" 31 | #include "dcel/arrangement.h" 32 | #include "input_manager.h" 33 | #include "input_parameters.h" 34 | #include "math/template_point.h" 35 | 36 | #include 37 | 38 | #include 39 | 40 | #include 41 | #include 42 | 43 | class FileWriter { 44 | public: 45 | FileWriter(InputParameters& ip, InputData& input, Arrangement& m, std::vector& points); 46 | 47 | template 48 | static T& write_grades(T& stream, const std::vector& x_exact, const std::vector& y_exact) 49 | { 50 | 51 | //write x-grades 52 | stream << "x-grades" << std::endl; 53 | for (std::vector::const_iterator it = x_exact.cbegin(); it != x_exact.cend(); ++it) { 54 | std::ostringstream oss; 55 | oss << *it; 56 | stream << oss.str() << std::endl; 57 | } 58 | stream << std::endl; 59 | 60 | //write y-grades 61 | stream << "y-grades" << std::endl; 62 | for (std::vector::const_iterator it = y_exact.cbegin(); it != y_exact.cend(); ++it) { 63 | std::ostringstream oss; 64 | oss << *it; 65 | stream << oss.str() << std::endl; 66 | } 67 | stream << std::endl; 68 | return stream; 69 | } 70 | 71 | void write_augmented_arrangement(std::ofstream& file); 72 | 73 | private: 74 | InputData& input_data; 75 | InputParameters& input_params; 76 | Arrangement& arrangement; //reference to the DCEL arrangement 77 | std::vector& template_points; //stores discrete coordinates of xi support points, with multiplicities 78 | }; 79 | 80 | #endif // FILEWRITER_H 81 | -------------------------------------------------------------------------------- /interface/input_manager.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | /** 21 | * \class InputManager 22 | * \brief The InputManager is able to identify the type of input 23 | */ 24 | 25 | #ifndef __InputManager_H__ 26 | #define __InputManager_H__ 27 | 28 | #include "dcel/barcode_template.h" 29 | #include "interface/file_input_reader.h" 30 | #include "interface/input_parameters.h" 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | //TODO: the input manager doesn't really hold an appreciable 37 | //amount of state, there's really no reason to instantiate a class 38 | //for this job, a collection of functions would do. 39 | 40 | //now the InputManager class 41 | class InputManager { 42 | public: 43 | InputManager(InputParameters& input_params); 44 | 45 | void start(); //function that parses input file for key values 46 | 47 | static std::string join(const std::vector& strings) 48 | { 49 | std::stringstream ss; 50 | for (size_t i = 0; i < strings.size(); i++) { 51 | if (i > 0) 52 | ss << " "; 53 | ss << strings[i]; 54 | } 55 | return ss.str(); 56 | } 57 | 58 | static std::vector split(std::string& str, std::string separators) 59 | { 60 | std::vector strings; 61 | boost::split(strings, str, boost::is_any_of(separators)); 62 | return strings; 63 | } 64 | 65 | bool type_set; // specifies if datatype was set in file 66 | 67 | private: 68 | InputParameters& input_params; //parameters supplied by the user 69 | int verbosity; //controls display of output, for debugging 70 | 71 | int to_skip; // stores the number of non-data lines in the input file 72 | 73 | void parse_args(); // goes through supplied arguments and sets parameters 74 | 75 | // methods to support parsing the old file formats 76 | void parse_points_old(); 77 | void parse_metric_old(); 78 | void parse_bifiltration_old(); 79 | void parse_firep_old(); 80 | 81 | bool is_flag(std::string str); // determines if a line in the input file is an input parameter 82 | }; 83 | 84 | #endif // __InputManager_H__ 85 | -------------------------------------------------------------------------------- /interface/input_parameters.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef INPUT_PARAMETERS_H 22 | #define INPUT_PARAMETERS_H 23 | 24 | #include 25 | 26 | #include 27 | typedef boost::multiprecision::cpp_rational exact; 28 | //TODO: this class currently conflates 3 things: command line arguments, file load dialog arguments, and viewer configuration state 29 | 30 | // Error that is raised when the input file does not match format correctly 31 | class InputError : public std::runtime_error { 32 | public: 33 | InputError(unsigned line, std::string message) 34 | : std::runtime_error("line " + std::to_string(line) + ": " + message) 35 | { 36 | } 37 | }; 38 | 39 | //these parameters are set by the user via the console or the DataSelectDialog before computation can begin 40 | struct InputParameters { 41 | std::string fileName; //name of data file 42 | std::string shortName; //name of data file, without path 43 | std::string outputFile; //name of the file where the augmented arrangement should be saved 44 | int hom_degree; //degree of homology to compute 45 | int x_bins; //number of bins for x-coordinate (if 0, then bins are not used for x) 46 | int y_bins; //number of bins for y-coordinate (if 0, then bins are not used for y) 47 | int verbosity; //controls the amount of console output printed 48 | std::string x_label; //used by configuration dialog 49 | std::string y_label; //used by configuration dialog 50 | std::string outputFormat; // Supported values: R0, R1 51 | int num_threads; //number of openmp threads to be created 52 | bool binary; //include binary data in MI file 53 | bool minpres; //print minimal presentation and exit 54 | bool betti; //print betti number information 55 | bool bounds; //print lower and upper bounds of module in MI file 56 | bool koszul; //use koszul homology based algorithm 57 | exact max_dist; //maximum distance to be considered while building Rips complex 58 | std::string md_string; //holds max distance in string format 59 | unsigned dimension; //dimension of the space where the points lie 60 | bool old_function; //specifies if the data has a function value like the old format 61 | bool new_function; //specifies if the data has function values in the new format 62 | bool x_reverse, y_reverse; //specifies if the axes need to be reversed or not 63 | std::string type; //type of file being worked with 64 | std::string bifil; //type of bifiltration to build 65 | int to_skip; //number of lines after which the actual data begins 66 | std::string function_type; //type of function values to calculate 67 | double filter_param; //parameter value for calculating function values 68 | 69 | InputParameters() 70 | { 71 | // default values for all input parameters - should include first 3? 72 | type = "points"; 73 | bifil = ""; 74 | hom_degree = 0; 75 | x_bins = 0; 76 | y_bins = 0; 77 | verbosity = 0; 78 | outputFormat = "msgpack"; 79 | num_threads = 0; 80 | old_function = false; 81 | new_function = false; 82 | max_dist = -1; 83 | dimension = 0; 84 | x_reverse = false; 85 | y_reverse = false; 86 | x_label = ""; 87 | y_label = "distance"; 88 | binary = false; 89 | minpres = false; 90 | betti = false; 91 | bounds = false; 92 | koszul = false; 93 | filter_param = 0; 94 | function_type = "none"; 95 | } 96 | 97 | template 98 | void serialize(Archive& ar, const unsigned int /*version*/) 99 | { 100 | ar& fileName& shortName& outputFile& hom_degree& x_bins& y_bins& verbosity& x_label& y_label& outputFormat; 101 | } 102 | MSGPACK_DEFINE(fileName, shortName, outputFile, hom_degree, x_bins, y_bins, verbosity, x_label, y_label, outputFormat); 103 | }; 104 | 105 | #endif // INPUT_PARAMETERS_H 106 | -------------------------------------------------------------------------------- /interface/persistence_bar.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "persistence_bar.h" 22 | 23 | #include "config_parameters.h" 24 | #include "slice_diagram.h" 25 | 26 | PersistenceBar::PersistenceBar(SliceDiagram* s_diagram, ConfigParameters* params, double unscaled_start, double unscaled_end, unsigned index) 27 | : sdgm(s_diagram) 28 | , config_params(params) 29 | , start(unscaled_start) 30 | , end(unscaled_end) 31 | , class_index(index) 32 | , pressed(false) 33 | , secondary(false) 34 | , hover(false) 35 | , width(params->persistenceBarWidth) 36 | { 37 | setAcceptHoverEvents(true); 38 | } 39 | 40 | QRectF PersistenceBar::boundingRect() const 41 | { 42 | return shape().boundingRect(); 43 | } 44 | 45 | QPainterPath PersistenceBar::shape() const 46 | { 47 | QPainterPath path; 48 | QPainterPathStroker stroker; 49 | path.moveTo(0, 0); 50 | path.lineTo(dx, dy); 51 | stroker.setWidth(width); 52 | return stroker.createStroke(path); 53 | } 54 | 55 | void PersistenceBar::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*unused*/, QWidget* /*unused*/) 56 | { 57 | QPen pen(config_params->persistenceColor); 58 | pen.setWidth(config_params->persistenceBarWidth); 59 | 60 | if (pressed) { 61 | pen.setColor(config_params->persistenceHighlightColor); 62 | } 63 | if (secondary) { 64 | pen.setStyle(Qt::DashLine); 65 | } 66 | 67 | painter->setRenderHint(QPainter::Antialiasing); 68 | painter->setPen(pen); 69 | painter->drawLine(0, 0, dx, dy); 70 | } 71 | 72 | void PersistenceBar::set_line(double start_x, double start_y, double end_x, double end_y) 73 | { 74 | prepareGeometryChange(); 75 | setPos(start_x, start_y); 76 | dx = end_x - start_x; 77 | dy = end_y - start_y; 78 | } 79 | 80 | void PersistenceBar::set_width(int bar_width) 81 | { 82 | prepareGeometryChange(); 83 | width = bar_width; 84 | } 85 | 86 | void PersistenceBar::select() 87 | { 88 | pressed = true; 89 | update(); 90 | } 91 | 92 | void PersistenceBar::select_secondary() 93 | { 94 | pressed = true; 95 | secondary = true; 96 | update(); 97 | } 98 | 99 | void PersistenceBar::deselect() 100 | { 101 | pressed = false; 102 | secondary = false; 103 | update(); 104 | } 105 | 106 | double PersistenceBar::get_start() 107 | { 108 | return start; 109 | } 110 | 111 | double PersistenceBar::get_end() 112 | { 113 | return end; 114 | } 115 | 116 | unsigned PersistenceBar::get_index() 117 | { 118 | return class_index; 119 | } 120 | 121 | void PersistenceBar::hoverEnterEvent(QGraphicsSceneHoverEvent* /*unused*/) 122 | { 123 | hover = true; 124 | update(); 125 | } 126 | 127 | void PersistenceBar::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*unused*/) 128 | { 129 | hover = false; 130 | update(); 131 | } 132 | 133 | void PersistenceBar::mousePressEvent(QGraphicsSceneMouseEvent* /*unused*/) 134 | { 135 | if (pressed) //then unselect this bar 136 | { 137 | pressed = false; 138 | //call slice diagram unselect function 139 | sdgm->deselect_bar(); 140 | } else //then select this bar 141 | { 142 | pressed = true; 143 | //call slice diagram select function 144 | sdgm->select_bar(this); 145 | } 146 | 147 | // update(); 148 | // QGraphicsItem::mousePressEvent(event); 149 | } 150 | 151 | void PersistenceBar::mouseReleaseEvent(QGraphicsSceneMouseEvent* /*unused*/) 152 | { 153 | // pressed = false; 154 | // update(); 155 | // QGraphicsItem::mouseReleaseEvent(event); 156 | } 157 | -------------------------------------------------------------------------------- /interface/persistence_bar.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef PERSISTENCE_BAR_H 22 | #define PERSISTENCE_BAR_H 23 | 24 | //forward declarations 25 | struct ConfigParameters; 26 | class SliceDiagram; 27 | 28 | //#include 29 | #include 30 | #include 31 | 32 | class PersistenceBar : public QGraphicsItem { 33 | public: 34 | PersistenceBar(SliceDiagram* s_diagram, ConfigParameters* params, double unscaled_start, double unscaled_end, unsigned index); 35 | 36 | QRectF boundingRect() const; 37 | QPainterPath shape() const; 38 | 39 | void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*); 40 | 41 | void set_line(double start_x, double start_y, double end_x, double end_y); 42 | void set_width(int bar_width); 43 | 44 | void select(); 45 | void select_secondary(); 46 | void deselect(); 47 | 48 | double get_start(); //returns the unscaled x-coordinate associated with this bar 49 | double get_end(); //returns the unscaled y-coordinate associated with this bar 50 | unsigned get_index(); //returns the index of this bar (e.g. to send to the PersistenceDiagram for highlighting effects) 51 | 52 | protected: 53 | void hoverEnterEvent(QGraphicsSceneHoverEvent*); 54 | void hoverLeaveEvent(QGraphicsSceneHoverEvent*); 55 | void mousePressEvent(QGraphicsSceneMouseEvent*); 56 | void mouseReleaseEvent(QGraphicsSceneMouseEvent*); 57 | 58 | private: 59 | SliceDiagram* sdgm; 60 | ConfigParameters* config_params; 61 | 62 | double start; //unscaled start coordinate (projection units) 63 | double end; //unscaled end coordinate (projection units) 64 | unsigned class_index; //index of the dot corresponding to this bar in the Barcode object 65 | 66 | bool pressed; 67 | bool secondary; 68 | bool hover; 69 | double dx; //horizontal length of line (pixels) 70 | double dy; //vertical length of line (pixels) 71 | int width; //width of the bar (pixels) 72 | }; 73 | 74 | #endif // PERSISTENCE_BAR_H 75 | -------------------------------------------------------------------------------- /interface/persistence_dot.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "persistence_dot.h" 22 | 23 | #include "config_parameters.h" 24 | #include "persistence_diagram.h" 25 | 26 | #include 27 | 28 | PersistenceDot::PersistenceDot(PersistenceDiagram* p_diagram, ConfigParameters* params, double unscaled_x, double unscaled_y, unsigned multiplicity, double radius, unsigned index) 29 | : pdgm(p_diagram) 30 | , config_params(params) 31 | , x(unscaled_x) 32 | , y(unscaled_y) 33 | , multiplicity(multiplicity) 34 | , radius(radius) 35 | , pressed(false) 36 | , hover(false) 37 | { 38 | indexes.push_back(index); 39 | 40 | setAcceptHoverEvents(true); 41 | // setFlag(ItemSendsGeometryChanges); 42 | } 43 | 44 | QRectF PersistenceDot::boundingRect() const 45 | { 46 | return QRectF(-radius, -radius, 2 * radius, 2 * radius); 47 | } 48 | 49 | void PersistenceDot::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*unused*/, QWidget* /*unused*/) 50 | { 51 | QRectF rect = boundingRect(); 52 | QBrush brush(config_params->persistenceColor); 53 | 54 | if (hover) 55 | painter->setPen(QPen(QBrush(config_params->persistenceHighlightColor), 3)); 56 | else 57 | painter->setPen(Qt::NoPen); 58 | 59 | if (pressed) 60 | brush.setColor(config_params->persistenceHighlightColor); 61 | 62 | painter->setRenderHint(QPainter::Antialiasing); 63 | // painter->setPen(Qt::NoPen); 64 | painter->setBrush(brush); 65 | painter->drawEllipse(rect); 66 | } 67 | 68 | void PersistenceDot::select() 69 | { 70 | pressed = true; 71 | update(boundingRect()); 72 | } 73 | 74 | void PersistenceDot::deselect() 75 | { 76 | pressed = false; 77 | update(boundingRect()); 78 | } 79 | 80 | //adds another "barcode" index to this dot 81 | void PersistenceDot::add_index(unsigned index) 82 | { 83 | indexes.push_back(index); 84 | } 85 | 86 | //increases the multiplicity of this dot by m 87 | void PersistenceDot::incr_multiplicity(unsigned m) 88 | { 89 | multiplicity += m; 90 | } 91 | 92 | //returns the unscaled x-coordinate associated with this dot 93 | double PersistenceDot::get_x() 94 | { 95 | return x; 96 | } 97 | 98 | //returns the unscaled y-coordinate associated with this dot 99 | double PersistenceDot::get_y() 100 | { 101 | return y; 102 | } 103 | 104 | //returns the "barcode" indexes of this dot (e.g. to send to the SliceDiagram for highlighting effects) 105 | std::vector PersistenceDot::get_indexes() 106 | { 107 | return indexes; 108 | } 109 | 110 | //returns the multiplicity of this dot 111 | unsigned PersistenceDot::get_multiplicity() 112 | { 113 | return multiplicity; 114 | } 115 | 116 | //sets a new radius and re-draws the dot 117 | void PersistenceDot::set_radius(double r) 118 | { 119 | radius = r; 120 | update(boundingRect()); 121 | } 122 | 123 | void PersistenceDot::hoverEnterEvent(QGraphicsSceneHoverEvent* /*unused*/) 124 | { 125 | hover = true; 126 | update(boundingRect()); 127 | } 128 | 129 | void PersistenceDot::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*unused*/) 130 | { 131 | hover = false; 132 | update(boundingRect()); 133 | } 134 | 135 | void PersistenceDot::mousePressEvent(QGraphicsSceneMouseEvent* /*unused*/) 136 | { 137 | if (pressed) //then unselect this dot 138 | { 139 | pressed = false; 140 | //call persistence diagram unselect function 141 | pdgm->deselect_dot(); 142 | } else //then select this dot 143 | { 144 | pressed = true; 145 | //call persistence diagram select function 146 | pdgm->select_dot(this); 147 | } 148 | 149 | update(boundingRect()); 150 | // QGraphicsItem::mousePressEvent(event); 151 | } 152 | 153 | void PersistenceDot::mouseReleaseEvent(QGraphicsSceneMouseEvent* /*unused*/) 154 | { 155 | // pressed = false; 156 | // update(); 157 | // QGraphicsItem::mouseReleaseEvent(event); 158 | } 159 | -------------------------------------------------------------------------------- /interface/persistence_dot.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef PERSISTENCE_DOT_H 22 | #define PERSISTENCE_DOT_H 23 | 24 | //forward declarations 25 | struct ConfigParameters; 26 | class PersistenceDiagram; 27 | 28 | #include 29 | #include 30 | 31 | class PersistenceDot : public QGraphicsItem { 32 | public: 33 | PersistenceDot(PersistenceDiagram* p_diagram, ConfigParameters* params, double unscaled_x, double unscaled_y, unsigned multiplicity, double radius, unsigned index); 34 | 35 | QRectF boundingRect() const; 36 | void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*); 37 | 38 | void select(); 39 | void deselect(); 40 | 41 | void add_index(unsigned index); //adds another "barcode" index to this dot 42 | void incr_multiplicity(unsigned m); //increases the multiplicity of this dot by m 43 | 44 | double get_x(); //returns the unscaled x-coordinate associated with this dot 45 | double get_y(); //returns the unscaled y-coordinate associated with this dot 46 | std::vector get_indexes(); //returns the "barcode" indexes of this dot (e.g. to send to the SliceDiagram for highlighting effects) 47 | unsigned get_multiplicity(); //returns the multiplicity of this dot 48 | 49 | void set_radius(double r); //sets a new radius and re-draws the dot 50 | 51 | protected: 52 | void hoverEnterEvent(QGraphicsSceneHoverEvent*); 53 | void hoverLeaveEvent(QGraphicsSceneHoverEvent*); 54 | void mousePressEvent(QGraphicsSceneMouseEvent*); 55 | void mouseReleaseEvent(QGraphicsSceneMouseEvent*); 56 | 57 | private: 58 | PersistenceDiagram* pdgm; 59 | ConfigParameters* config_params; 60 | 61 | double x; //unscaled x-coordinate (projection units) 62 | double y; //unscaled y-coordinate (projection units) 63 | std::vector indexes; //indexes of this dot in the vector PersistenceDiagram::dots_by_bc_index (more than one index are possible because dots get combined in the upper horizontal strip of the persistence diagram) 64 | unsigned multiplicity; //number of bars represented by this dot 65 | double radius; 66 | bool pressed; 67 | bool hover; 68 | }; 69 | 70 | #endif // PERSISTENCE_DOT_H 71 | -------------------------------------------------------------------------------- /interface/progress.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | // 21 | // Created by Bryn Keller on 5/17/16. 22 | // 23 | 24 | #include "progress.h" 25 | -------------------------------------------------------------------------------- /interface/progress.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | // 21 | // Created by Bryn Keller on 5/17/16. 22 | // 23 | #pragma once 24 | #include 25 | #include 26 | 27 | class Progress { 28 | 29 | public: 30 | boost::signals2::signal setProgressMaximum; 31 | boost::signals2::signal advanceProgressStage; 32 | boost::signals2::signal progress; 33 | }; 34 | -------------------------------------------------------------------------------- /interface/progressdialog.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "progressdialog.h" 22 | #include "ui_progressdialog.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | ProgressDialog::ProgressDialog(QWidget* parent) 30 | : QDialog(parent) 31 | , ui(new Ui::ProgressDialog) 32 | , current_stage(1) 33 | , stage_maximum(100) 34 | , computation_finished(false) 35 | { 36 | ui->setupUi(this); 37 | this->setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint); 38 | 39 | stage_progress.push_back(0); 40 | stage_progress.push_back(5); //we'll say that when the file is read we are 5% done, 41 | stage_progress.push_back(15); // and when the bifiltration is built we are 15% done, 42 | stage_progress.push_back(65); // and when the Betti numbers are computed we are 65% done 43 | stage_progress.push_back(80); // and when the line arrangement is built we are 80% done 44 | stage_progress.push_back(100); // and when the barcode templates are computed we are 100% done 45 | } 46 | 47 | ProgressDialog::~ProgressDialog() 48 | { 49 | delete ui; 50 | } 51 | 52 | void ProgressDialog::advanceToNextStage() 53 | { 54 | QLabel* prevLabel = getLabel(current_stage); 55 | QFont font = prevLabel->font(); 56 | font.setBold(false); 57 | prevLabel->setFont(font); 58 | 59 | current_stage++; 60 | 61 | //TODO: Why is this here? --Mike. 62 | //stage_maximum = 100; 63 | 64 | QLabel* nextLabel = getLabel(current_stage); 65 | 66 | font.setBold(true); 67 | nextLabel->setFont(font); 68 | nextLabel->setEnabled(true); 69 | 70 | ui->progressBar->setValue(stage_progress[current_stage - 1]); 71 | } 72 | 73 | void ProgressDialog::setStageMaximum(unsigned max) 74 | { 75 | stage_maximum = max; 76 | } 77 | 78 | void ProgressDialog::updateProgress(unsigned current) 79 | { 80 | double stage_percent = ((double)current) / stage_maximum; 81 | int value = (int)(stage_percent * (stage_progress[current_stage] - stage_progress[current_stage - 1]) + stage_progress[current_stage - 1]); 82 | ui->progressBar->setValue(value); 83 | } 84 | 85 | void ProgressDialog::setComputationFinished() 86 | { 87 | computation_finished = true; 88 | close(); 89 | } 90 | 91 | void ProgressDialog::closeEvent(QCloseEvent* event) 92 | { 93 | if (!computation_finished) 94 | event->ignore(); 95 | else { 96 | event->accept(); 97 | QWidget::closeEvent(event); 98 | } 99 | } 100 | 101 | QLabel* ProgressDialog::getLabel(unsigned i) 102 | { 103 | if (i == 1) 104 | return ui->step1description; 105 | else if (i == 2) 106 | return ui->step2description; 107 | else if (i == 3) 108 | return ui->step3description; 109 | else if (i == 4) 110 | return ui->step4description; 111 | else 112 | return ui->step5description; 113 | } 114 | 115 | void ProgressDialog::on_stopButton_clicked() 116 | { 117 | QMessageBox::StandardButton reallyStop; 118 | reallyStop = QMessageBox::question(this, "Stop computation?", "Are you sure you want to stop the computation?", QMessageBox::Yes | QMessageBox::No); 119 | 120 | if (reallyStop == QMessageBox::Yes) { 121 | emit stopComputation(); 122 | computation_finished = true; 123 | close(); 124 | qDebug() << "COMPUTATION INTERRUPTED BY USER"; 125 | qobject_cast(this->parent())->close(); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /interface/progressdialog.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef PROGRESSDIALOG_H 22 | #define PROGRESSDIALOG_H 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | namespace Ui { 30 | class ProgressDialog; 31 | } 32 | 33 | class ProgressDialog : public QDialog { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit ProgressDialog(QWidget* parent = 0); 38 | ~ProgressDialog(); 39 | 40 | public slots: 41 | void advanceToNextStage(); 42 | void setStageMaximum(unsigned max); 43 | void updateProgress(unsigned current); 44 | void setComputationFinished(); 45 | 46 | protected: 47 | void closeEvent(QCloseEvent*); 48 | 49 | signals: 50 | void stopComputation(); 51 | 52 | private slots: 53 | void on_stopButton_clicked(); 54 | 55 | private: 56 | Ui::ProgressDialog* ui; 57 | std::vector stage_progress; 58 | unsigned current_stage; 59 | unsigned stage_maximum; 60 | bool computation_finished; 61 | 62 | QLabel* getLabel(unsigned i); 63 | }; 64 | 65 | #endif // PROGRESSDIALOG_H 66 | -------------------------------------------------------------------------------- /interface/progressdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ProgressDialog 4 | 5 | 6 | Qt::NonModal 7 | 8 | 9 | true 10 | 11 | 12 | 13 | 0 14 | 0 15 | 400 16 | 210 17 | 18 | 19 | 20 | 21 | 0 22 | 0 23 | 24 | 25 | 26 | 27 | 400 28 | 210 29 | 30 | 31 | 32 | 33 | 400 34 | 210 35 | 36 | 37 | 38 | RIVET: Computation in Progress 39 | 40 | 41 | true 42 | 43 | 44 | 45 | 46 | 150 47 | 170 48 | 100 49 | 27 50 | 51 | 52 | 53 | Stop 54 | 55 | 56 | 57 | 58 | 59 | 10 60 | 135 61 | 381 62 | 23 63 | 64 | 65 | 66 | 0 67 | 68 | 69 | 70 | 71 | 72 | 10 73 | 15 74 | 371 75 | 21 76 | 77 | 78 | 79 | 80 | 75 81 | true 82 | 83 | 84 | 85 | Reading input file... 86 | 87 | 88 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 89 | 90 | 91 | 92 | 93 | false 94 | 95 | 96 | 97 | 10 98 | 37 99 | 371 100 | 21 101 | 102 | 103 | 104 | Building bifiltration... 105 | 106 | 107 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 108 | 109 | 110 | 111 | 112 | false 113 | 114 | 115 | 116 | 10 117 | 59 118 | 371 119 | 21 120 | 121 | 122 | 123 | Computing presentation and bigraded Betti numbers... 124 | 125 | 126 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 127 | 128 | 129 | 130 | 131 | false 132 | 133 | 134 | 135 | 10 136 | 81 137 | 371 138 | 21 139 | 140 | 141 | 142 | Building line arrangement... 143 | 144 | 145 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 146 | 147 | 148 | 149 | 150 | false 151 | 152 | 153 | 154 | 10 155 | 103 156 | 371 157 | 21 158 | 159 | 160 | 161 | Computing barcode templates... 162 | 163 | 164 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /interface/slice_line.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef SLICE_LINE_H 22 | #define SLICE_LINE_H 23 | 24 | //forward declarations 25 | struct ConfigParameters; 26 | class ControlDot; 27 | class SliceDiagram; 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class SliceLine : public QGraphicsItem { 35 | public: 36 | SliceLine(SliceDiagram* sd, ConfigParameters* params); //VisualizationWindow* vw); 37 | 38 | void setDots(ControlDot* left, ControlDot* right); 39 | 40 | QRectF boundingRect() const; 41 | QPainterPath shape() const; 42 | 43 | void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*); 44 | 45 | QVariant itemChange(GraphicsItemChange change, const QVariant& value); 46 | 47 | void update_lb_endpoint(); //updates left-bottom endpoint; called by ControlDot on move event 48 | void update_rt_endpoint(); //updates right-top endpoint; called by ControlDot on move event 49 | 50 | double get_right_pt_x(); //gets x-coordinate of right-top endpoint (units: pixels) 51 | double get_right_pt_y(); //gets y-coordinate of right-top endpoint (units: pixels) 52 | 53 | double get_slope(); //gets the slope of the line 54 | bool is_vertical(); //true if the line is vertical, false otherwise 55 | 56 | void update_bounds(double data_width, double data_height, int padding); //updates the dimensions of the on-screen box in which this line is allowed to move 57 | void update_position(double xpos, double ypos, bool vert, double pixel_slope); //updates position of line; called by SliceDiagram in response to change in VisualizationWindow controls 58 | 59 | double get_data_xmax(); 60 | double get_data_ymax(); 61 | double get_box_xmax(); 62 | double get_box_ymax(); 63 | 64 | void set_visibility(bool visible); 65 | bool is_inside_view(); 66 | 67 | protected: 68 | void mousePressEvent(QGraphicsSceneMouseEvent* event); 69 | void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); 70 | void mouseMoveEvent(QGraphicsSceneMouseEvent* event); 71 | 72 | private: 73 | double data_xmax, data_ymax; //pixel dimensions slightly greater than the largest bounds of the current window 74 | double box_xmax, box_ymax; //pixel dimensions of the on-screen box in which this line is allowed to move 75 | 76 | bool vertical; //true if the line is currently vertical 77 | double slope; //current slope of the line in PIXEL units 78 | 79 | bool pressed; //true when the line is clicked 80 | bool rotating; //true when a rotation is in progress 81 | bool update_lock; //true when the line is being moved as result of external input; to avoid update loops 82 | 83 | QPointF right_point; //this is the top/right endpoint of the line 84 | 85 | ControlDot* left_dot; 86 | ControlDot* right_dot; 87 | 88 | SliceDiagram* sdgm; 89 | ConfigParameters* config_params; 90 | 91 | bool inside_view = true; 92 | void compute_right_point(); //sets correct position of right_point, given slope of line and position of left point 93 | }; 94 | 95 | #endif // SLICE_LINE_H 96 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "api.h" 22 | #include "interface/input_parameters.h" 23 | #include "visualizationwindow.h" 24 | 25 | #include "dcel/arrangement_message.h" 26 | #include "dcel/dcel.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | Q_DECLARE_SMART_POINTER_METATYPE(std::shared_ptr) 33 | Q_DECLARE_METATYPE(TemplatePointsMessage) 34 | Q_DECLARE_METATYPE(ArrangementMessage) 35 | Q_DECLARE_METATYPE(std::shared_ptr) 36 | Q_DECLARE_METATYPE(std::shared_ptr) 37 | 38 | int main(int argc, char* argv[]) 39 | { 40 | InputParameters params; //parameter values stored here 41 | 42 | //create the appropriate application object 43 | QApplication app(argc, argv); 44 | QCoreApplication::setApplicationName("RIVET"); 45 | QCoreApplication::setOrganizationName("RIVET developers"); 46 | QCoreApplication::setOrganizationDomain("rivet.online"); 47 | QCoreApplication::setApplicationVersion("0.4"); 48 | 49 | //define the command line options 50 | QCommandLineParser parser; 51 | parser.setApplicationDescription( 52 | QCoreApplication::translate("main", 53 | "RIVET: Rank Invariant Visualization and Exploration Tool\n" 54 | "This is the RIVET viewer (GUI) application.\n" 55 | "There is also a command line tool called rivet_console.\n\n" 56 | "For more information, see the RIVET website at https://rivet.online.")); 57 | auto helpOption = parser.addHelpOption(); 58 | auto versionOption = parser.addVersionOption(); 59 | QCommandLineOption verbosityOption(QStringList() << "V" 60 | << "verbosity", 61 | QCoreApplication::translate("main", "Verbosity level: 0 (no console output) to 10 (lots of output)."), 62 | QCoreApplication::translate("main", "integer"), "2"); 63 | parser.addOption(verbosityOption); 64 | 65 | //parse the command line options 66 | parser.process(app); 67 | 68 | params.hom_degree = 0; 69 | params.verbosity = parser.value(verbosityOption).toInt(); 70 | params.x_bins = 0; 71 | params.y_bins = 0; 72 | 73 | qRegisterMetaType>(); 74 | qRegisterMetaType>(); 75 | 76 | //now run RIVET 77 | if (!(parser.isSet(helpOption) || parser.isSet(versionOption))) { 78 | VisualizationWindow v_window(params); 79 | v_window.show(); 80 | 81 | return app.exec(); 82 | } 83 | 84 | } //end main() 85 | -------------------------------------------------------------------------------- /math/bigraded_matrix.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2018 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | /* 22 | 23 | Author: Michael Lesnick (2017) 24 | 25 | 26 | Class: BigradedMatrix 27 | 28 | Description: This is a wrapper class which stores a MapMatrix 29 | and an associated IndexMatrix. Most important method is kernel(). 30 | Used when columns are sorted in colex order of their bigrades of appearance. 31 | 32 | 33 | Class: BigradedMatrixLex 34 | 35 | Description: This is a similar wrapper class which stores a MapMatrix and an 36 | associated IndexMatrixLex. Used when columns are sorted in lex order of their 37 | bigrades of appearance. 38 | 39 | */ 40 | 41 | #ifndef __Bigraded_Matrix_H__ 42 | #define __Bigraded_Matrix_H__ 43 | 44 | #include "index_matrix.h" 45 | #include "map_matrix.h" 46 | 47 | //forward declarations 48 | class MapMatrix; 49 | class vector_heap; 50 | class IndexMatrix; 51 | class IndexMatrixLex; 52 | 53 | class BigradedMatrixLex; 54 | class BigradedMatrix { 55 | public: 56 | //column-sparse matrix 57 | MapMatrix mat; 58 | //bigrade info for each column of mat. Columns are assumed to be in colex 59 | //order. 60 | IndexMatrix ind; 61 | 62 | //Constructor. Builds an zero matrix of the appropropriate dimensions 63 | BigradedMatrix(unsigned rows, unsigned cols, unsigned ind_rows, unsigned ind_cols); 64 | 65 | //Constructor. Copies the arguments. 66 | BigradedMatrix(const MapMatrix& m, const IndexMatrix& i); 67 | 68 | /* 69 | Constructor taking a BigradedMatrixLex object. Moves the cols of lex_mat 70 | into this matrix, and builds the corresponding index matrix. 71 | Also trivializes lex_mat in the process. 72 | */ 73 | BigradedMatrix(BigradedMatrixLex& lex_mat); 74 | 75 | //Compute the kernel of this bigraded matrix via a standard reduction: 76 | //NOTE: This destroys the matrix. 77 | BigradedMatrix kernel(); 78 | 79 | void print(); 80 | 81 | private: 82 | /* 83 | Performs a step of the kernel computation at a single bigrade. This is a 84 | variant on the standard bigraded reduction. When a column in mat is zeroed 85 | out, the corresponding column of slave is appended to the back 86 | working_ker.mat, and then zeroed out in the slave. The function also 87 | records the bigrades of the generators for the kernel by updating 88 | working_ker.ind. 89 | */ 90 | void kernel_one_bigrade(MapMatrix& slave, 91 | BigradedMatrixLex& ker_lex, 92 | unsigned curr_x, 93 | unsigned curr_y, 94 | std::vector& lows); 95 | }; 96 | 97 | //Similar to BigradedMatrix, but columns are assumed to be in lex order. 98 | class BigradedMatrixLex { 99 | public: 100 | MapMatrix mat; 101 | IndexMatrixLex ind; 102 | 103 | //constructor 104 | BigradedMatrixLex(unsigned rows, 105 | unsigned cols, 106 | unsigned ind_rows, 107 | unsigned ind_cols) 108 | : mat(rows, cols) 109 | , ind(ind_rows, ind_cols) 110 | { 111 | } 112 | 113 | void print(); 114 | }; 115 | 116 | #endif // __Bigraded_Matrix_H__ 117 | -------------------------------------------------------------------------------- /math/bool_array.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | // 21 | // Created by Bryn Keller on 11/22/16. 22 | // 23 | 24 | #include "bool_array.h" 25 | 26 | bool_array::bool_array(unsigned long rows, unsigned long cols) 27 | : cols(cols) 28 | , array(new bool[rows * cols]) 29 | { 30 | } 31 | 32 | bool& bool_array::at(unsigned long row, unsigned long col) { return array[row * cols + col]; } 33 | -------------------------------------------------------------------------------- /math/bool_array.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | // 21 | // Created by Bryn Keller on 11/22/16. 22 | // 23 | 24 | #ifndef RIVET_CONSOLE_BOOL_ARRAY_H 25 | #define RIVET_CONSOLE_BOOL_ARRAY_H 26 | 27 | #include 28 | //Helper class to manage dynamically sized 2d arrays of bools. Not a serious array class, just a helper for 29 | //a specific use case. 30 | class bool_array { 31 | public: 32 | bool_array(unsigned long rows, unsigned long cols); 33 | bool& at(unsigned long row, unsigned long col); 34 | 35 | private: 36 | unsigned long cols; 37 | std::unique_ptr array; 38 | }; 39 | 40 | #endif //RIVET_CONSOLE_BOOL_ARRAY_H 41 | -------------------------------------------------------------------------------- /math/distance_matrix.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef _DISTANCE_MATRIX_H 22 | #define _DISTANCE_MATRIX_H 23 | 24 | #include "../interface/data_reader.h" 25 | #include "../interface/file_input_reader.h" 26 | #include "../interface/input_parameters.h" 27 | 28 | #include 29 | #include 30 | 31 | class DistanceMatrix { 32 | public: 33 | DistanceMatrix(InputParameters& params, int np); 34 | ~DistanceMatrix(); // cleanup all data structures used in distance matrix 35 | 36 | void build_distance_matrix(std::vector& points); // builds a distance matrix from a set of points 37 | 38 | void build_all_vectors(InputData* data); // builds discrete index vectors and grade vectors 39 | 40 | void read_distance_matrix(std::vector& values); // reads a matrix from an input file and stores it 41 | 42 | void ball_density_estimator(double radius); // function to add a ball density estimator to provided data 43 | void knn_density_estimator(int k); // function calculate distance to kth nearest neighbor of every point 44 | void eccentricity_estimator(int p); // function calculate eccentricity of every point 45 | void gaussian_estimator(double s); 46 | 47 | // these are required by bifiltration data and hence made public 48 | std::vector dist_indexes; 49 | std::vector function_indexes; 50 | std::vector degree_indexes; 51 | 52 | unsigned* degree; 53 | 54 | private: 55 | InputParameters& input_params; 56 | 57 | // some commonly used variables in the class 58 | // they are set from the input parameters 59 | bool function; 60 | unsigned num_points; 61 | exact max_dist; 62 | unsigned max_degree; 63 | unsigned dimension; 64 | std::string filtration; 65 | std::string func_type; 66 | 67 | unsigned max_unsigned; // infinity 68 | 69 | // sets storing unique values 70 | ExactSet dist_set; 71 | ExactSet degree_set; 72 | ExactSet function_set; 73 | 74 | std::pair ret; // for return value upon inserting to a set 75 | 76 | exact approx(double x); 77 | void build_grade_vectors(InputData& data, ExactSet& value_set, std::vector& indexes, std::vector& grades_exact, unsigned num_bins); //converts an ExactSets of values to the vectors of discrete values that BifiltrationData uses to build the bifiltration, and also builds the grade vectors (floating-point and exact) 78 | }; 79 | 80 | #endif -------------------------------------------------------------------------------- /math/grade.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2017 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | /* 22 | 23 | Author: Roy Zhao (2017) 24 | 25 | Struct: Grade 26 | 27 | Description: Pair of coordinates specifying grade of appearance, 28 | together with an operator < which compares COLEXICOGRAPHICALLY, 29 | i.e., first by y-coordinate, then by x-coordinate. 30 | NOTE: This Struct appeared earlier in bifiltration_data.h. Since the same struct is 31 | useful elsewhere, it is better in its own file. 32 | 33 | */ 34 | 35 | #ifndef grade_h 36 | #define grade_h 37 | 38 | struct Grade { 39 | int x; 40 | int y; 41 | 42 | bool operator==(const Grade& other) const 43 | { 44 | return x == other.x && y == other.y; 45 | } 46 | 47 | bool operator<(const Grade& other) const 48 | { 49 | if (y != other.y) 50 | return y < other.y; 51 | else 52 | return x < other.x; 53 | } 54 | 55 | Grade() {} 56 | 57 | Grade(int set_x, int set_y) 58 | : x(set_x) 59 | , y(set_y) 60 | { 61 | } 62 | }; 63 | 64 | #endif /* grade_h */ 65 | -------------------------------------------------------------------------------- /math/index_matrix.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2018 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | /* 21 | 22 | Authors: Matthew L. Wright (July 2014), Michael Lesnick (modifications 2017-2018) 23 | 24 | 25 | Class: IndexMatrix 26 | 27 | Description: Implicitly stores a list of bigrades in colexicographical order as a (dense) matrix. 28 | Typically, the list of bigrades corresponds to the columns of a matrix, stored as a MapMatrix object; 29 | The IndexMatrix and MapMatrix together represent a morphism of free bigraded modules. 30 | (See also the BigradedMatrix class). 31 | 32 | The entry of the IndexMatrix at (row, col) is to be the greatest column index of all columns that 33 | appear at or before (row, col) in colexicographical order, or -1 34 | if there are no such columns. This representation can save memory when one has 35 | relatively few different x-grades and y-grades and many columns. 36 | Note though that this representation may be much *less* memory efficient than a naive representation 37 | when one has many x- and y-grades. 38 | 39 | 40 | Class: IndexMatrixLex : IndexMatrix 41 | 42 | Description: Similar to the parent class, but for lists of bigrades in lexicographical order 43 | 44 | */ 45 | 46 | #ifndef __IndexMatrix_H__ 47 | #define __IndexMatrix_H__ 48 | 49 | #include "grade.h" 50 | #include 51 | 52 | class IndexMatrix { 53 | public: 54 | //Initialize each entry in the matrix to be -1. 55 | IndexMatrix(unsigned rows, unsigned cols); 56 | 57 | void set(unsigned row, unsigned col, int value); 58 | 59 | //Returns the entry at (row,col) (see above). 60 | int get(unsigned row, unsigned col) const; 61 | 62 | int last() const; 63 | 64 | unsigned width() const; //returns number of columns 65 | unsigned height() const; //returns number of rows 66 | 67 | //utility function which gives the next index in the matrix, w.r.t. colex order. 68 | //NOTE: directly increments row and col. For the last index (num_rows-1,num_columns-1), this will increment 69 | //to (num_rows,0) which is outside of the grid. This edge case behavior is convenient in the firep class. 70 | // For input indices not in the grid, an error is thrown. 71 | 72 | //TODO:Make static? 73 | void next_colex(int& row, int& col); 74 | 75 | //returns the index of the first column whose bigrade is at least (row,col) in colex order, or one larger than the largest column index if there is no such column. 76 | //returns an int for consisteny with get. 77 | int start_index(unsigned row, unsigned col); 78 | 79 | //returns the number of columns in the bigraded matrix of index 80 | //less than or equal to the given bigraded in the partial order on R^2 81 | unsigned num_columns_leq(unsigned row, unsigned col); 82 | 83 | //technical utility function for setting the index matrices. 84 | //sets each entry of the index matrix in the colex interval [start_grade,end_grade) to value 85 | //As a side effect, sets start_grade equal to end_grade 86 | void fill_index_mx(Grade& start_grade, const Grade& end_grade, const unsigned& value); 87 | 88 | void print() const; //prints the matrix 89 | 90 | //print the colex-ordered vector of bigrades that this object represents 91 | void print_bigrades_vector() const; 92 | 93 | protected: 94 | unsigned num_rows; 95 | unsigned num_cols; 96 | std::vector data; 97 | }; 98 | 99 | //Same as parent class but uses the lex order. 100 | class IndexMatrixLex : public IndexMatrix { 101 | public: 102 | //Initialize each entry in the matrix to be -1. 103 | IndexMatrixLex(unsigned rows, unsigned cols); 104 | 105 | //definition of start_index is different than for the parent class 106 | int start_index(unsigned row, unsigned col); 107 | 108 | //print the lex-ordered vector of bigrades that this object represents 109 | void print_bigrades_vector() const; 110 | }; 111 | 112 | #endif // __IndexMatrix_H__ 113 | -------------------------------------------------------------------------------- /math/phat_mod/include/phat/helpers/misc.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 IST Austria 2 | Contributed by: Ulrich Bauer, Michael Kerber, Jan Reininghaus 3 | 4 | This file is part of PHAT. 5 | 6 | PHAT is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | PHAT is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PHAT. If not, see . */ 18 | 19 | #pragma once 20 | 21 | // STL includes 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | // VS2008 and below unfortunately do not support stdint.h 40 | #if defined(_MSC_VER)&& _MSC_VER < 1600 41 | typedef __int8 int8_t; 42 | typedef unsigned __int8 uint8_t; 43 | typedef __int16 int16_t; 44 | typedef unsigned __int16 uint16_t; 45 | typedef __int32 int32_t; 46 | typedef unsigned __int32 uint32_t; 47 | typedef __int64 int64_t; 48 | typedef unsigned __int64 uint64_t; 49 | #else 50 | #include 51 | #endif 52 | 53 | // basic types. index can be changed to int32_t to save memory on small instances 54 | namespace phat { 55 | typedef int64_t index; 56 | typedef int8_t dimension; 57 | typedef std::vector< index > column; 58 | } 59 | 60 | // OpenMP (proxy) functions 61 | #if defined _OPENMP 62 | #include 63 | #else 64 | #define omp_get_thread_num() 0 65 | #define omp_get_max_threads() 1 66 | #define omp_get_num_threads() 1 67 | inline void omp_set_num_threads( int ) {}; 68 | #include 69 | #define omp_get_wtime() (float)clock() / (float)CLOCKS_PER_SEC 70 | #endif 71 | 72 | #include "thread_local_storage.h" 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /math/phat_mod/include/phat/helpers/thread_local_storage.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 IST Austria 2 | Contributed by: Ulrich Bauer, Michael Kerber, Jan Reininghaus 3 | 4 | This file is part of PHAT. 5 | 6 | PHAT is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | PHAT is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PHAT. If not, see . */ 18 | 19 | #pragma once 20 | 21 | #include "misc.h" 22 | 23 | // should ideally be equal to the cache line size of the CPU 24 | #define PHAT_TLS_SPACING_FACTOR 64 25 | 26 | // ThreadLocalStorage with some spacing to avoid "false sharing" (see wikipedia) 27 | template< typename T > 28 | class thread_local_storage 29 | { 30 | public: 31 | 32 | thread_local_storage() : per_thread_storage( omp_get_max_threads() * PHAT_TLS_SPACING_FACTOR ) {}; 33 | 34 | T& operator()() { 35 | return per_thread_storage[ omp_get_thread_num() * PHAT_TLS_SPACING_FACTOR ]; 36 | } 37 | 38 | const T& operator()() const { 39 | return per_thread_storage[ omp_get_thread_num() * PHAT_TLS_SPACING_FACTOR ]; 40 | } 41 | 42 | T& operator[]( int tid ) { 43 | return per_thread_storage[ tid * PHAT_TLS_SPACING_FACTOR ]; 44 | } 45 | 46 | const T& operator[]( int tid ) const { 47 | return per_thread_storage[ tid * PHAT_TLS_SPACING_FACTOR ]; 48 | } 49 | 50 | protected: 51 | std::vector< T > per_thread_storage; 52 | }; 53 | -------------------------------------------------------------------------------- /math/sparse_matrix.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \class SparseMatrix 3 | * \brief Child of PHAT's boundry_matrix Class. Adds additional functionality needed by RIVET. 4 | * \author Matthew Wright and Michael Lesnick 5 | * \date July 2016, Oct. 2017. 6 | */ 7 | 8 | //This class is adapted from Matthew's extension of phat::boundary_matrix in July 2016. In order to minimize confusion, it seems best to keep PHAT and RIVET separate to the fullest extent possible, so we have transfered the additional functionalilty of the extension to a child class of boundary_matrix. 9 | 10 | #pragma once 11 | 12 | /********** TESTING PHAT MATRIX STRUCTURES **********/ 13 | 14 | #include "helpers/misc.h" 15 | #include "phat/boundary_matrix.h" 16 | #include "phat/representations/vector_heap.h" 17 | //#include "phat/representations/vector_list.h" 18 | //#include "phat/representations/vector_set.h" 19 | //#include "phat/representations/vector_vector.h" 20 | //#include "phat/representations/bit_tree_pivot_column.h" 21 | 22 | template 23 | class SparseMatrix : public phat::boundary_matrix { 24 | 25 | protected: 26 | index matrix_height; 27 | 28 | public: 29 | // height 30 | unsigned height() const { return (unsigned)matrix_height; } 31 | 32 | // width 33 | unsigned width() const { return (unsigned)rep._get_num_cols(); } 34 | 35 | // low 36 | int low(unsigned i) const { return (int)rep._get_max_index((index)i); } 37 | 38 | // operators / constructors 39 | public: 40 | SparseMatrix() 41 | : boundary_matrix() 42 | { 43 | } 44 | 45 | //constructor for a matrix of a certain size 46 | sparse_matrix(unsigned rows, unsigned cols) 47 | : boundary_matrix() 48 | , matrix_height((index)rows) 49 | { 50 | set_num_cols((index)cols); 51 | } 52 | 53 | //constructor for an identity matrix of a certain size 54 | 55 | SparseMatrix(unsigned size) 56 | : boundary_matrix() 57 | , matrix_height((index)size) 58 | { 59 | set_num_cols((index)size); 60 | std::vector temp_col; 61 | for (index i = 0; i < matrix_height; i++) { 62 | temp_col.push_back(i); 63 | set_col(i, temp_col); 64 | temp_col.clear(); 65 | } 66 | } 67 | 68 | //output for testing RIVET 69 | template 70 | void save_dense(std::vector>& output_matrix) 71 | { 72 | const index nr_of_columns = get_num_cols(); 73 | output_matrix.resize(nr_of_columns); 74 | column temp_col; 75 | for (index cur_col = 0; cur_col < nr_of_columns; cur_col++) { 76 | get_col(cur_col, temp_col); 77 | output_matrix[cur_col].clear(); 78 | output_matrix[cur_col].resize(matrix_height, 0); 79 | for (index cur_row = 0; cur_row < temp_col.size(); cur_row++) 80 | output_matrix[cur_col][temp_col[cur_row]] = 1; 81 | } 82 | } 83 | }; 84 | -------------------------------------------------------------------------------- /math/template_point.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #include "template_point.h" 22 | 23 | TemplatePoint::TemplatePoint(unsigned xc, unsigned yc, int m0, int m1, int m2) 24 | : x(xc) 25 | , y(yc) 26 | , zero(m0) 27 | , one(m1) 28 | , two(m2) 29 | { 30 | } 31 | 32 | TemplatePoint::TemplatePoint() 33 | : x(0) 34 | , y(0) 35 | , zero(0) 36 | , one(0) 37 | , two(0) 38 | { 39 | } 40 | 41 | bool operator==(TemplatePoint const& left, TemplatePoint const& right) 42 | { 43 | return left.one == right.one 44 | && left.two == right.two 45 | && left.x == right.x 46 | && left.y == right.y 47 | && left.zero == right.zero; 48 | } 49 | -------------------------------------------------------------------------------- /math/template_point.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef TEMPLATE_POINT_H 22 | #define TEMPLATE_POINT_H 23 | 24 | #include "dcel/msgpack_adapters.h" 25 | #include 26 | 27 | //class to store xi points, to help send data from the Arrangement to the VisualizationWindow 28 | class TemplatePoint { 29 | public: 30 | unsigned x, y; //coordinates (discrete) 31 | int zero, one, two; //multiplicities of xi_0, xi_1, and xi_2 at this point ---- TODO: maybe should be unsigned? 32 | 33 | TemplatePoint(unsigned xc, unsigned yc, int m0, int m1, int m2); 34 | TemplatePoint(); //for serialization 35 | 36 | friend bool operator==(TemplatePoint const& left, TemplatePoint const& right); 37 | 38 | template 39 | void serialize(Archive& archive, const unsigned int /*version*/) 40 | { 41 | archive& x& y& zero& one& two; 42 | } 43 | MSGPACK_DEFINE(x, y, zero, one, two); 44 | }; 45 | 46 | #endif // TEMPLATE_POINT_H 47 | -------------------------------------------------------------------------------- /math/template_points_matrix.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | #ifndef TEMPLATE_POINT_MATRIX_H 22 | #define TEMPLATE_POINT_MATRIX_H 23 | 24 | //forward declarations 25 | class MultiBetti; 26 | struct Multigrade; 27 | class TemplatePoint; 28 | class Arrangement; 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | //// these are the nodes in the sparse matrix 35 | struct TemplatePointsMatrixEntry { 36 | //data structures 37 | unsigned x; //discrete x-grade of this support point 38 | unsigned y; //discrete y-grade of this support point 39 | unsigned index; //index of this support point in the vector of support points stored in VisualizationWindow 40 | 41 | TemplatePointsMatrixEntry* down; //pointer to the next support point below this one 42 | TemplatePointsMatrixEntry* left; //pointer to the next support point left of this one 43 | 44 | std::list low_simplices; //associated multigrades for simplices of lower dimension 45 | std::list high_simplices; //associated multigrades for simplices of higher dimension 46 | 47 | unsigned low_count; //number of columns in matrix of simplices of lower dimension that are mapped to this TemplatePointsMatrixEntry 48 | unsigned high_count; //number of columns in matrix of simplices of higher dimension that are mapped to this TemplatePointsMatrixEntry 49 | unsigned low_index; //index of rightmost column in matrix of simplices of lower dimension that is mapped to this TemplatePointsMatrixEntry 50 | unsigned high_index; //index of rightmost column in matrix of simplices of higher dimension that is mapped to this TemplatePointsMatrixEntry 51 | //NOTE: if TemplatePointsMatrixEntry is a LUB-index but there are no low (resp. high) columns mapped to it, then low_index (resp. high_index) is the index of the column just left of where such columns would appear (could be -1) 52 | 53 | //functions 54 | TemplatePointsMatrixEntry(); //empty constructor 55 | TemplatePointsMatrixEntry(unsigned x, unsigned y, unsigned i, TemplatePointsMatrixEntry* d, TemplatePointsMatrixEntry* l); //regular constructor 56 | TemplatePointsMatrixEntry(unsigned x, unsigned y); //constructor for temporary entries used in counting switches 57 | 58 | void add_multigrade(unsigned x, unsigned y, unsigned num_cols, int index, bool low); //associates a (new) multigrades to this xi entry 59 | //the "low" argument is true if this multigrade is for low_simplices, and false if it is for high_simplices 60 | 61 | void insert_multigrade(Multigrade* mg, bool low); //inserts a Multigrade at the end of the list for the given dimension; does not update column counts! 62 | }; 63 | 64 | //// each TemplatePointsMatrixEntry maintains two lists of multigrades 65 | struct Multigrade { 66 | unsigned x; //x-coordinate of this multigrade 67 | unsigned y; //y-coordinate of this multigrade 68 | 69 | unsigned num_cols; //number of columns (i.e. simplices) at this multigrade 70 | int simplex_index; //last dim_index of the simplices at this multigrade; necessary so that we can build the boundary matrix, and also used for non-vineyard updates to the RU-decomposition 71 | 72 | Multigrade(unsigned x, unsigned y, unsigned num_cols, int simplex_index); //constructor 73 | 74 | Multigrade(); // For serialization 75 | 76 | static bool LexComparator(const Multigrade& first, const Multigrade& second); //comparator for sorting Multigrades lexicographically 77 | }; 78 | 79 | //// sparse matrix to store the set U of support points of the multi-graded Betti numbers 80 | //// Also known as 'tPtsMat' in the RIVET paper. 81 | class TemplatePointsMatrix { 82 | public: 83 | TemplatePointsMatrix(unsigned width, unsigned height); //constructor 84 | 85 | std::vector fill_and_find_anchors(std::vector& xi_pts); //stores xi support points in the xiSupportMatrix 86 | //also finds anchors, which are stored both in the matrix and in the vector xi_pts 87 | //precondition: xi_pts contains the support points in lexicographical order 88 | 89 | TemplatePointsMatrixEntry* get_row(unsigned r); //gets a pointer to the rightmost entry in row r; returns NULL if row r is empty 90 | TemplatePointsMatrixEntry* get_col(unsigned c); //gets a pointer to the top entry in column c; returns NULL if column c is empty 91 | 92 | unsigned height(); //retuns the number of rows; 93 | 94 | void clear_grade_lists(); //clears the level set lists for all entries in the matrix 95 | 96 | private: 97 | std::vector columns; 98 | std::vector rows; 99 | }; 100 | 101 | #endif // TEMPLATE_POINT_MATRIX_H 102 | -------------------------------------------------------------------------------- /numerics.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | // 21 | // Created by Bryn Keller on 6/21/16. 22 | // 23 | 24 | #ifndef RIVET_CONSOLE_NUMERICS_H 25 | #define RIVET_CONSOLE_NUMERICS_H 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | typedef boost::multiprecision::cpp_rational exact; 33 | 34 | typedef boost::multi_array unsigned_matrix; 35 | 36 | namespace rivet { 37 | namespace numeric { 38 | exact str_to_exact(const std::string& str); 39 | bool is_number(const std::string& str); 40 | std::vector to_doubles(const std::vector exacts); 41 | double project_to_line(double angle, double offset, double x_0, double y_0); 42 | const double INFTY(std::numeric_limits::infinity()); 43 | const double PI(3.14159265358979323846); 44 | } 45 | } 46 | 47 | #endif //RIVET_CONSOLE_NUMERICS_H 48 | -------------------------------------------------------------------------------- /pointer_comparator.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Bryn Keller on 6/29/16. 23 | // 24 | 25 | #ifndef RIVET_CONSOLE_POINTER_COMPARATOR_H 26 | #define RIVET_CONSOLE_POINTER_COMPARATOR_H 27 | 28 | template 29 | class PointerComparator { 30 | 31 | public: 32 | Comparator comparator; 33 | 34 | bool operator()(const std::unique_ptr &lhs, const std::unique_ptr &rhs) const //returns true if lhs comes before rhs 35 | { 36 | return comparator(*lhs, *rhs); 37 | } 38 | bool operator()(const std::shared_ptr lhs, const std::shared_ptr rhs) const //returns true if lhs comes before rhs 39 | { 40 | return comparator(*lhs, *rhs); 41 | } 42 | bool operator()(const T* lhs, const T* rhs) const //returns true if lhs comes before rhs 43 | { 44 | return comparator(*lhs, *rhs); 45 | } 46 | }; 47 | #endif //RIVET_CONSOLE_POINTER_COMPARATOR_H 48 | -------------------------------------------------------------------------------- /run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "This script will compare rivet_console output against historical references" 3 | echo "The diffs that print below should differ only in file creation date" 4 | 5 | build/rivet_console data/circle_data_60pts.txt test.rivet -H1 -x10 -y10 -f R0 6 | diff data/ref/circle_data_60pts.txt_H1_10x10.txt test.rivet 7 | 8 | build/rivet_console data/circle_data_240pts_inv_density.txt test.rivet -H0 -x5 -y5 -f R0 9 | diff data/ref/circle_data_240pts_inv_density.txt_H0_5x5.txt test.rivet 10 | 11 | build/rivet_console data/circle_data_240pts_inv_density.txt test.rivet -H1 -x10 -y10 -f R0 12 | diff data/ref/circle_data_240pts_inv_density.txt_H1_10x10.txt test.rivet 13 | 14 | build/rivet_console data/circle_data_240pts_inv_density.txt test.rivet -H2 -x5 -y5 -f R0 15 | diff data/ref/circle_data_240pts_inv_density.txt_H2_5x5.txt test.rivet 16 | 17 | build/rivet_console data/circle_data_400pts_inv_density.txt test.rivet -H1 -x10 -y10 -f R0 18 | diff data/ref/circle_data_400pts_inv_density_H1_10x10.txt test.rivet -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeFiles 2 | CMakeCache.txt 3 | unit_tests 4 | cmake_install.cmake -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.1) 2 | set (CMAKE_CXX_STANDARD 11) 3 | project (rivet_tests) 4 | add_executable (unit_tests 5 | unit_tests.cpp 6 | ../timer.cpp 7 | ../math/map_matrix.cpp 8 | ../debug.cpp 9 | ../numerics.cpp 10 | ../computation.cpp 11 | ../interface/progress.cpp 12 | ../interface/file_writer.cpp 13 | ../interface/file_input_reader.cpp 14 | ../interface/input_manager.cpp 15 | ../interface/data_reader.cpp 16 | ../dcel/arrangement.cpp 17 | ../dcel/anchor.cpp 18 | ../dcel/barcode_template.cpp 19 | ../dcel/dcel.cpp 20 | ../math/map_matrix.cpp 21 | ../math/multi_betti.cpp 22 | ../math/template_point.cpp 23 | ../math/template_points_matrix.cpp 24 | ../math/index_matrix.cpp 25 | ../math/persistence_updater.cpp 26 | ../dcel/arrangement_builder.cpp 27 | ) 28 | 29 | include_directories("${PROJECT_SOURCE_DIR}/..") 30 | -------------------------------------------------------------------------------- /test/data_reader_tests.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Bryn Keller on 6/21/16. 3 | // 4 | 5 | #ifndef RIVET_CONSOLE_DATA_READER_TESTS_H 6 | #define RIVET_CONSOLE_DATA_READER_TESTS_H 7 | 8 | #endif //RIVET_CONSOLE_INPUT_MANAGER_TESTS_H 9 | 10 | #include "catch.hpp" 11 | #include "interface/data_reader.h" 12 | #include "numerics.h" 13 | #include 14 | #include 15 | 16 | TEST_CASE("DataPoint parses correctly", "[InputManager]") 17 | { 18 | std::vector data{ "1.0", "-1.2", "1.12" }; 19 | DataPoint point(data); 20 | 21 | REQUIRE(point.coords[0] == 1.0); 22 | REQUIRE(point.coords[1] == -1.2); 23 | REQUIRE(point.birth == exact(112, 100)); 24 | } 25 | -------------------------------------------------------------------------------- /test/exact_ops.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Bryn Keller on 6/21/16. 3 | // 4 | 5 | #ifndef RIVET_CONSOLE_EXACT_OPS_H 6 | #define RIVET_CONSOLE_EXACT_OPS_H 7 | 8 | #endif //RIVET_CONSOLE_EXACT_OPS_H 9 | 10 | #include "catch.hpp" 11 | #include "numerics.h" 12 | #include 13 | #include 14 | 15 | TEST_CASE("Exact parser parses 12.34", "[Exact]") 16 | { 17 | 18 | exact v = rivet::numeric::str_to_exact("12.34"); 19 | REQUIRE(v == exact(1234, 100)); 20 | } 21 | 22 | TEST_CASE("Exact parser parses 765", "[Exact]") 23 | { 24 | 25 | exact v = rivet::numeric::str_to_exact("765"); 26 | REQUIRE(v == exact(765)); 27 | } 28 | 29 | TEST_CASE("Exact parser parses -10.8421", "[Exact]") 30 | { 31 | 32 | exact v = rivet::numeric::str_to_exact("-10.8421"); 33 | REQUIRE(v == exact(-108421, 10000)); 34 | } 35 | -------------------------------------------------------------------------------- /test/map_matrix_tests.h: -------------------------------------------------------------------------------- 1 | #include "catch.hpp" 2 | #include "math/map_matrix.h" 3 | #include 4 | #include 5 | 6 | /* 7 | 8 | TEST_CASE("MapMatrix can be initialized", "[MapMatrix]") 9 | { 10 | 11 | MapMatrix mat = MapMatrix(3, 4); 12 | REQUIRE(mat.height() == 3); 13 | REQUIRE(mat.width() == 4); 14 | 15 | MapMatrix eye = MapMatrix(3); 16 | 17 | MapMatrix manual_eye = MapMatrix(3, 3); 18 | 19 | manual_eye.set(0, 0); 20 | manual_eye.set(1, 1); 21 | 22 | REQUIRE(!(eye == manual_eye)); 23 | 24 | manual_eye.set(2, 2); 25 | 26 | REQUIRE(eye == manual_eye); 27 | 28 | MapMatrix explicit_eye = { 29 | { 1, 0, 0 }, 30 | { 0, 1, 0 }, 31 | { 0, 0, 1 } 32 | }; 33 | 34 | REQUIRE(eye == explicit_eye); 35 | } 36 | 37 | TEST_CASE("MapMatrix.add_column works" 38 | "[MapMatrix]") 39 | { 40 | MapMatrix eye = MapMatrix(3); 41 | 42 | MapMatrix test = { 43 | { 1, 0, 0 }, 44 | { 0, 0, 1 }, 45 | { 1, 1, 1 } 46 | }; 47 | 48 | test.add_column(1, 0); 49 | test.add_column(2, 1); 50 | test.add_column(1, 2); 51 | 52 | REQUIRE(test == eye); 53 | } 54 | 55 | */ 56 | 57 | //not true, apparently: 58 | /* TEST_CASE( "MapMatrix.col_reduce reduces columns" "[MapMatrix]") { */ 59 | 60 | /* MapMatrix eye = MapMatrix(3); */ 61 | 62 | /* MapMatrix test = { */ 63 | /* {1, 0, 0}, */ 64 | /* {0, 0, 1}, */ 65 | /* {1, 1, 1} */ 66 | /* }; */ 67 | 68 | /* test.col_reduce(); */ 69 | 70 | /* REQUIRE( test == eye ); */ 71 | /* } */ 72 | -------------------------------------------------------------------------------- /test/output_test/readme.txt: -------------------------------------------------------------------------------- 1 | FILES: 2 | 3 | 1. run_tests.sh - Contains all tests for RIVET Output. 4 | 5 | 2. correct - Contains expected output of all the tests. 6 | 7 | 3. latest - Contains output from latest run of run_tests.sh. 8 | 9 | 4. test_data - Contains all the data files for testing. 10 | 11 | 5. rivet-test - The module invariants file generated during testing. 12 | 13 | USAGE: 14 | 15 | > Run tests from the "test/output_test" folder. 16 | > Simply run "./run_tests.sh". 17 | > It will run the tests, compare the outputs and say if tests passed or failed. 18 | > If you have failed tests, it will output the differences. 19 | > Read through to figure out which test(s) failed to help with debugging. 20 | > There are tests that are supposed to generate errors. 21 | > There is no output for these tests in the "correct" file. 22 | > The errors are in the terminal. 23 | > Look at the errors to determine if RIVET correctly catches errors. 24 | 25 | MODIFICATION: 26 | 27 | > Add tests at the end maintaining test numbers. 28 | > Look at other tests to understand how to write new tests. 29 | > Note that if a test is supposed to generate an error, it is written slightly differently. 30 | > Add comments if test is for a new flag. 31 | > To test with different file(s) or flag(s) you can add a "command" at the top where all the other commands are. 32 | > A "command" is run on the command line, with the arguments that are supplied in the tests. 33 | > If you add a test or modify a test, run_tests.sh will fail. 34 | > Once it fails, confirm that the result from the modified (or added) test is desirable. 35 | > Copy the newly generated latest file over the correct file. -------------------------------------------------------------------------------- /test/output_test/test_data/test-bifiltration1.txt: -------------------------------------------------------------------------------- 1 | --datatype bifiltration 2 | --xlabel x-label 3 | --ylabel y-label 4 | 0 ; 0 0 5 | 1 ; 0 0 6 | 2 ; 0 0 7 | 3 ; 0 0 8 | 0 1 ; 0 0 9 | 0 2 ; 0 0 10 | 1 2 ; 0 0 11 | 0 1 2 ; 1 0 12 | 1 3 ; 0 1 13 | 2 3 ; 0 1 -------------------------------------------------------------------------------- /test/output_test/test_data/test-firep_ex.txt: -------------------------------------------------------------------------------- 1 | --datatype firep 2 | --xlabel x-label 3 | --ylabel y-label 4 | 2 2 0 5 | 3 2 ; 0 6 | 2 3 ; 0 1 7 | 1 1 ; 8 | 2 2 ; -------------------------------------------------------------------------------- /test/output_test/test_data/test-metric_ex.txt: -------------------------------------------------------------------------------- 1 | --datatype metric_fn 2 | --xlabel function values 3 | 4 | --ylabel distance 5 | --maxdist 3 6 | 7 | # function values 8 | 0 1 0.5 1 0.7 9 | 10 | 0.2 2.5 3.4 0.5 11 | 0.4 2 2.8 12 | 0.6 4 13 | 1 -------------------------------------------------------------------------------- /test/output_test/test_data/test-metric_ex_2.txt: -------------------------------------------------------------------------------- 1 | --datatype metric 2 | 3 | --ylabel distance 4 | --maxdist 3 5 | 6 | 0.2 2.5 3.4 0.5 7 | 0.4 2 2.8 8 | 0.6 4 9 | 1 -------------------------------------------------------------------------------- /test/output_test/test_data/test-metric_ex_3.txt: -------------------------------------------------------------------------------- 1 | --datatype metric_fn 2 | --xlabel function values 3 | 4 | --ylabel distance 5 | --maxdist 3 6 | 7 | # function values 8 | 0 1 0.5 1 0.7 9 | 10 | -0, 0.2, 2.5, 3.4, 0.5 11 | 0.2, 0, 0.4, 2, 2.8 12 | 2.5, 0.4, 0, 0.6, 4 13 | 3.4, 2, 0.6, 0, 1 14 | 0.5, 2.8, 4, 1, 0 -------------------------------------------------------------------------------- /test/output_test/test_data/test-points2.txt: -------------------------------------------------------------------------------- 1 | --datatype points_fn 2 | #--maxdist 4 3 | --xbins 10 4 | --ybins 10 5 | --homology 1 6 | 7 | # function values 8 | 1,3.2,2,4,2.5,2.4,2 9 | 10 | 0.3, 1.5, 2.1 11 | 4.2, 3.8, 4.9 12 | 5.6, 2.3, 6 13 | 2.9, 5.1, 3.3 14 | 3.3, 2.0, 2.5 15 | 4.1, 1.1, 2.3 16 | 1.1, 1.3, 1.7 -------------------------------------------------------------------------------- /test/output_test/test_data/test-points2_1.txt: -------------------------------------------------------------------------------- 1 | #--datatype points 2 | #--maxdist 3.1 3 | --xbins 10 4 | --ybins 10 5 | 6 | --homology 1 7 | 0.3, 1.5, 2.1 8 | 4.2,3.8,4.9 9 | 5.6,2.3,6 10 | 2.9,5.1,3.3 11 | 3.3,2.0,2.5 12 | 4.1,1.1,2.3 13 | 1.1,1.3,1.7 -------------------------------------------------------------------------------- /test/serialization_tests.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Bryn Keller on 7/11/16. 3 | // 4 | 5 | #ifndef RIVET_CONSOLE_SERIALIZATION_TESTS_H_H 6 | #define RIVET_CONSOLE_SERIALIZATION_TESTS_H_H 7 | #include "dcel/anchor.h" 8 | #include "dcel/arrangement.h" 9 | #include "dcel/dcel.h" 10 | #include 11 | #include 12 | 13 | template 14 | T round_trip_msgpack(const T& thing) 15 | { 16 | std::stringstream ss; 17 | msgpack::pack(ss, thing); 18 | 19 | std::string buff(ss.str()); 20 | T result; 21 | auto oh = msgpack::unpack(buff.data(), buff.size()); 22 | auto obj = oh.get(); 23 | obj.convert(result); 24 | return result; 25 | } 26 | 27 | TEST_CASE("InputParameters can be roundtripped with msgpack", "[serialization - msgpack]") 28 | { 29 | 30 | InputParameters params; 31 | params.hom_degree = 0; 32 | params.outputFile = "bogus"; 33 | params.fileName = "inbogus"; 34 | params.outputFormat = "flergh"; 35 | params.x_bins = 10; 36 | params.y_bins = 10; 37 | params.x_label = "x"; 38 | params.y_label = "y"; 39 | 40 | InputParameters result = round_trip_msgpack(params); 41 | 42 | REQUIRE(params.hom_degree == result.hom_degree); 43 | REQUIRE(params.fileName == result.fileName); 44 | REQUIRE(params.outputFile == result.outputFile); 45 | REQUIRE(params.outputFormat == result.outputFormat); 46 | REQUIRE(result.outputFormat == "flergh"); 47 | REQUIRE(params.x_bins == result.x_bins); 48 | REQUIRE(params.y_bins == result.y_bins); 49 | REQUIRE(params.x_label == result.x_label); 50 | REQUIRE(params.y_label == result.y_label); 51 | } 52 | #endif //RIVET_CONSOLE_SERIALIZATION_TESTS_H_H 53 | -------------------------------------------------------------------------------- /test/unit_tests.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "catch.hpp" 3 | #include "data_reader_tests.h" 4 | #include "exact_ops.h" 5 | #include "map_matrix_tests.h" 6 | #include "serialization_tests.h" 7 | -------------------------------------------------------------------------------- /timer.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Bryn Keller on 5/19/16. 23 | // 24 | 25 | #include "timer.h" 26 | 27 | Timer::Timer() 28 | { 29 | start_time = std::chrono::system_clock::now(); 30 | } 31 | 32 | long Timer::elapsed() 33 | { 34 | return std::chrono::duration_cast(std::chrono::system_clock::now() - start_time).count(); 35 | } 36 | 37 | void Timer::restart() { start_time = std::chrono::system_clock::now(); } 38 | 39 | std::chrono::system_clock::time_point Timer::started() { return start_time; } 40 | -------------------------------------------------------------------------------- /timer.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Bryn Keller on 5/19/16. 23 | // 24 | 25 | #ifndef RIVET_CONSOLE_TIMER_H 26 | #define RIVET_CONSOLE_TIMER_H 27 | 28 | #include 29 | 30 | class Timer { 31 | public: 32 | Timer(); 33 | std::chrono::system_clock::time_point started(); 34 | void restart(); 35 | long elapsed(); 36 | 37 | private: 38 | std::chrono::system_clock::time_point start_time; 39 | }; 40 | 41 | #endif //RIVET_CONSOLE_TIMER_H 42 | -------------------------------------------------------------------------------- /type_tag.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | Copyright 2014-2016 The RIVET Developers. See the COPYRIGHT file at 3 | the top-level directory of this distribution. 4 | 5 | This file is part of RIVET. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | **********************************************************************/ 20 | 21 | // 22 | // Created by Bryn Keller on 7/14/16. 23 | // 24 | 25 | #ifndef RIVET_CONSOLE_TYPE_TAG_H 26 | #define RIVET_CONSOLE_TYPE_TAG_H 27 | 28 | #include 29 | 30 | //http://www.ilikebigbits.com/blog/2014/5/6/type-safe-identifiers-in-c 31 | template 32 | class ID { 33 | public: 34 | static ID invalid() { return ID(); } 35 | 36 | // Defaults to ID::invalid() 37 | ID() 38 | : m_val(default_value) 39 | { 40 | } 41 | 42 | // Explicit constructor: 43 | explicit ID(impl val) 44 | : m_val(val) 45 | { 46 | } 47 | 48 | // Explicit conversion to get back the impl: 49 | explicit operator impl() const { return m_val; } 50 | 51 | friend bool operator==(ID a, ID b) { return a.m_val == b.m_val; } 52 | friend bool operator!=(ID a, ID b) { return a.m_val != b.m_val; } 53 | 54 | MSGPACK_DEFINE(m_val); 55 | 56 | private: 57 | impl m_val; 58 | }; 59 | 60 | #endif //RIVET_CONSOLE_TYPE_TAG_H 61 | --------------------------------------------------------------------------------