// Copright (C) 1999-2021, Bernd Gaertner // November 12, 2021 // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // Contact: // -------- // Bernd Gaertner // Institute of Theoretical Computer Science // ETH Zuerich // CAB G31.1 // CH-8092 Zuerich, Switzerland // http://www.inf.ethz.ch/personal/gaertner // ========================================================================= // generates a set of random points, computes their smallest enclosing ball, // and outputs the characteristics of this ball // // usage: miniball_example_containers [seed] // ========================================================================= #include #include #include #include #include #include "Miniball.hpp" int main (int argc, char* argv[]) { typedef double mytype; // coordinate type const int d = 5; // dimension int n = 1000000; // number of points double seed; // initialize random number generator if (argc != 2) { seed = 0; } else seed = std::atoi(argv[1]); std::srand (seed); // generate random points and store them in a list of vectors // ---------------------------------------------------------- std::list > lp; for (int i=0; i p(d); for (int j=0; j >::const_iterator PointIterator; typedef std::vector::const_iterator CoordIterator; // create an instance of Miniball // ------------------------------ typedef Miniball:: Miniball > MB; MB mb (d, lp.begin(), lp.end()); // output results // -------------- // center std::cout << "Center:\n "; const mytype* center = mb.center(); for(int i=0; i