private static string FormatDouble(double x) { if (x > 0) { return(StatisticalTable.FormatDouble(x)); } else { return("--"); } }
private void CreateText(StringBuilder sb, IList <MachineRow> values, IList <double> arraySizeAverages) { const string columnSep = "@{~~}"; sb.AppendLine(@"\begin{tabular}{l | " + string.Join("|", Enumerable.Repeat("r", values.First().Values.Count)) + "||r|}"); sb.AppendLine(@"Machine & " + string.Join("&", values.First().Values.Select(v => v.ArraySize)) + " & Avg" + @"\\ \hline"); foreach (var machine in values) { sb.AppendLine($"{machine.MachineName} & " + string.Join("&", machine.Values.Select(v => FormatDouble(v.Factor))) + $"& {StatisticalTable.FormatDouble(machine.Average)}" + @"\\"); } sb.AppendLine(@"\hline"); sb.AppendLine("Average & " + string.Join("&", arraySizeAverages.Select(v => StatisticalTable.FormatDouble(v))) + "&" + StatisticalTable.FormatDouble(arraySizeAverages.Average())); sb.AppendLine(@"\end{tabular}"); }