/* Copyright (c) 1997-2009
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
   http://www.polymake.de

   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 2, or (at your option) any
   later version: http://www.gnu.org/licenses/gpl.txt.

   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.
--------------------------------------------------------------------------------
   $Project: polymake $$Id: rand_metric.cc 9513 2010-03-01 21:10:37Z herr $
*/

#include <polymake.h>
#include <Matrix.h>
#include <random_generators.h>

namespace polymake { namespace polytope {

perl::Object rand_metric(int n, perl::OptionSet options)
{
  UniformRNG< double > random_source(options["seed"] ? std::atol(options["seed"]) : random_seed());
  Matrix<double> metric(n,n);
  for(int i=0; i<n;++i)
    for(int j=i+1;j<n;++j)
      metric(i,j)=metric(j,i)=1+random_source.get();
  perl::Object p("TightSpan");  

  p.take("METRIC") << metric;
  return p;
}

  UserFunction4perl("# @category Producing from scratch"
		    "# Produce an //n//-point metric with random distances. The values are uniformily"
		    "# distributed in [1,2]."
		    "# @param Int n"
		    "# @option Int seed controls the outcome of the random number generator;"
		    "#   fixing a seed number guarantees the same outcome. "
		    "# @return Polytope",
		    &rand_metric,"rand_metric($ { seed => undef })");


} }
