diff options
Diffstat (limited to 'src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp')
-rw-r--r-- | src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp | 76 |
1 files changed, 34 insertions, 42 deletions
diff --git a/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp index 1e0caa30..9816ff1d 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp @@ -20,55 +20,47 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - - #include <gudhi/Persistence_landscape.h> - - using namespace Gudhi; using namespace Gudhi::Persistence_representations; #include <iostream> +int main(int argc, char** argv) { + std::cout << "This program computes average persistence landscape of persistence landscapes created based on " + "persistence diagrams provided as an input (you must create them first).\n"; + std::cout << "Please call this program with the names of files with persistence landscapes. The program will create " + "a persistence landscape which will be their average \n"; + std::vector<const char*> filenames; + + if (argc == 1) { + std::cout << "No input files given, the program will now terminate \n"; + return 1; + } + + for (int i = 1; i < argc; ++i) { + filenames.push_back(argv[i]); + } + + std::cout << "Creating persistence landscapes...\n"; + std::vector<Persistence_landscape*> lands; + for (size_t i = 0; i != filenames.size(); ++i) { + Persistence_landscape* l = new Persistence_landscape; + l->load_landscape_from_file(filenames[i]); + lands.push_back(l); + } + + Persistence_landscape av; + av.compute_average(lands); + + av.print_to_file("average.land"); + + for (size_t i = 0; i != filenames.size(); ++i) { + delete lands[i]; + } -int main( int argc , char** argv ) -{ - std::cout << "This program computes average persistence landscape of persistence landscapes created based on persistence diagrams provided as an input (you must create them first).\n"; - std::cout << "Please call this program with the names of files with persistence landscapes. The program will create a persistence landscape which will be their average \n"; - std::vector< const char* > filenames; - - if ( argc == 1 ) - { - std::cout << "No input files given, the program will now terminate \n"; - return 1; - } - - for ( int i = 1 ; i < argc ; ++i ) - { - filenames.push_back( argv[i] ); - } - - std::cout << "Creating persistence landscapes...\n"; - std::vector< Persistence_landscape* > lands; - for ( size_t i = 0 ; i != filenames.size() ; ++i ) - { - Persistence_landscape* l = new Persistence_landscape; - l->load_landscape_from_file( filenames[i] ); - lands.push_back( l ); - } - - Persistence_landscape av; - av.compute_average( lands ); - - av.print_to_file( "average.land" ); - - for ( size_t i = 0 ; i != filenames.size() ; ++i ) - { - delete lands[i]; - } - - std::cout << "Done \n"; + std::cout << "Done \n"; - return 0; + return 0; } |