-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfilter2tex.sh
executable file
·113 lines (106 loc) · 3.63 KB
/
filter2tex.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
stdlib="netlib netlibqap kenlib meslib pdslib raillib fctplib"
stdlang='en'
while getopts l:h name
do
case $name in
l)
lang="$OPTARG";;
h)
echo "Convert \`bench-*.out\` to LaTeX table format.";&
?)
echo 'Usage: analysis.sh [-l lang] lib ...'
echo ''
echo 'Avaliable languages:'
echo ''
echo ' * en (default)'
echo ' * pt'
echo ''
echo 'Avaliable test library:'
echo ''
echo ' * netlib'
echo ' * netlibqap'
echo ' * kenlib'
echo ' * meslib'
echo ' * pdslib'
echo ' * raillib'
echo ' * fctplib'
echo ''
echo 'If any argument is given it will run for all the library'
echo 'and specifications avaliable.'
exit 2;;
esac
done
if $(test ! -v lang)
then
lang=$stdlang
elif $(test -z $lang)
then
lang=$stdlang
fi
if $(test ! -v lib)
then
lib=$stdlib
elif $(test -z $lib)
then
lib=$stdlib
fi
for l in $lib
do
echo "Check if file \`bench-${l}.join\` exist."
if $(test ! -e bench-${l}.join)
then
echo "Can\'t find file \`bench-${l}.join\`. Aborting."
exit 2;
fi
echo "Generating LaTeX table(s) from \`bench-${l}.join\`."
ifilename=bench-${l}.join
ofilename=bench-${l}.join.tex
if $(test $lang = 'en')
then
echo '\begin{tabular}{|l|r|r|r|r|r|r|r|r|}' > $ofilename
echo '\hline' >> $ofilename
head -n 1 $ifilename | sed 's/,/ /g' | awk '{print \
"\\multicolumn{1}{|c|}{Problem} & \\multicolumn{4}{|c|}{" toupper($1) "} & \
\\multicolumn{4}{|c|}{" toupper($2) "} \\\\ \\hline"}' >> $ofilename
echo '\multicolumn{1}{|c|}{Name} & \multicolumn{1}{|c|}{R} &
\multicolumn{1}{|c|}{NNZ} & \multicolumn{1}{|c|}{IT} &
\multicolumn{1}{|c|}{T} & \multicolumn{1}{|c|}{R} &
\multicolumn{1}{|c|}{NNZ} & \multicolumn{1}{|c|}{IT} &
\multicolumn{1}{|c|}{T} \\ \hline' >> $ofilename
tail -n +3 $ifilename | sed 's/^[a-z]*-//; s/\.mps//; s/_/-/g; s/,/ \& /g;
s/$/ \\\\ \\hline/' >> $ofilename
echo '\end{tabular}' >> $ofilename
fi
if $(test $lang = 'pt')
then
echo '\begin{tabular}{|l|r|r|r|r|r|r|r|r|}' > $ofilename
echo '\hline' >> $ofilename
head -n 1 $ifilename | sed 's/,/ /g' | awk '{print \
"\\multicolumn{1}{|c|}{Problema} & \\multicolumn{4}{|c|}{" toupper($1) "} & \
\\multicolumn{4}{|c|}{" toupper($2) "} \\\\ \\hline"}' >> $ofilename
echo '\multicolumn{1}{|c|}{Nome} & \multicolumn{1}{|c|}{R} &
\multicolumn{1}{|c|}{NNZ} & \multicolumn{1}{|c|}{IT} &
\multicolumn{1}{|c|}{T} & \multicolumn{1}{|c|}{R} &
\multicolumn{1}{|c|}{NNZ} & \multicolumn{1}{|c|}{IT} &
\multicolumn{1}{|c|}{T} \\ \hline' >> $ofilename
tail -n +3 $ifilename | sed 's/^[a-z]*-//; s/\.mps//; s/_/-/g; s/,/ \& /g; s/\./,/g;
s/$/ \\\\ \\hline/' >> $ofilename
echo '\end{tabular}' >> $ofilename
fi
# Split file if it has more than 40 lines
if $(test $(( ($(wc -l < $ofilename) - 9) / 40 + 1)) -gt 1)
then
header=$(head -n 8 $ofilename)
footer=$(tail -n 1 $ofilename)
head -n -1 $ofilename | tail -n +5 | split -a 1 -d -l 40 - x
for i in $(seq 0 $(( ($(wc -l < $ofilename) - 9) / 40)) )
do
echo $header > ${ofilename}$i
cat x$i >> ${ofilename}$i
echo $footer >> ${ofilename}$i
done
fi
# Remove temporary files
rm -f x[0-9]*
done