/* 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 9757 2010-08-09 15:50:29Z sherrmann $
*/

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

namespace polymake { namespace polytope {

Matrix<double> 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();

  return metric;
}


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 Matrix",
		    &rand_metric,"rand_metric($ { seed => undef })");


} }
