let latex oc
?(samples_in_rows=false)
?(cols=10)
?(fill=false)
?(rotate_titles=true)
string_of_key string_of_dist dm =
let p = Printf.fprintf in
let len = Array.length dm.dist_elements in
let f_begin i =
p oc "\\begin{tabular}{|l|";
for k = i to min (i + cols - 1) (len - 1) do p oc "r|" done;
p oc "}\n\\hline\n";
for k = i to min (i + cols - 1) (len - 1) do
if rotate_titles then
p oc "& \\rotatebox{90}{%s}" (string_of_key dm.dist_elements.(k))
else
p oc "& %s" (string_of_key dm.dist_elements.(k))
done;
if samples_in_rows then
(
p oc "\\\\\n\\hline\nsamples";
for k = i to min (i + cols - 1) (len - 1) do
p oc "& (%d)" dm.dist_samples.(k)
done;
);
p oc "\\\\\n\\hline\n"
in
let f_end () =
p oc "\\end{tabular}\n\n"
in
let rec iter i =
if i < len then
(
f_begin i;
for j = 0 to len - 1 do
p oc "%s " (string_of_key dm.dist_elements.(j)) ;
for k = i to min (i + cols - 1) (len - 1) do
if fill or j <= k then
p oc "& %s" (string_of_dist dm.dist_matrix.(k).(j))
else
p oc "& ";
done;
p oc "\\\\\n\\hline\n";
done;
f_end ();
iter (i + cols)
)
else
()
in
iter 0