require ("xfig");
require ("readascii");

define read_data (file, ncol, expr_col)
{
   variable s = struct
     {
	n, expr
     };
   () = readascii (file, &s.n, &s.expr; cols=[ncol,expr_col]);
   return s;
}
   
define slsh_main ()
{
   variable slang = read_data ("data/slang_discr.dat", 1,2);
   variable numarray = read_data ("data/python_discr.dat", 1,3);
   variable numeric = read_data ("data/python_discr.dat", 1,2);

   variable w = xfig_plot_new ();
   w.world (1, max(slang.n)*1.05, 0, 1; logx);
   w.xlabel ("Array Size"; size="large");
   w.ylabel ("Fraction of S-Lang Speed"; size="large");
   w.plot (slang.n, slang.expr/numeric.expr; color="red");
   w.plot (slang.n, slang.expr/numarray.expr; color="blue");
   variable legend = xfig_new_legend (["Numeric", "numarray"],
				      ["red", "blue"], 0, 2, 2);
   w.add_object (legend, 40, 0.7);
   w.title("Evaluation of $\sqrt{b^2-4ac}$"R; size="Large");
   w.render ("numarray.png");
}
