File: texprint.e

package info (click to toggle)
euler 1.61.0-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 5,164 kB
  • sloc: ansic: 24,761; sh: 8,314; makefile: 141; cpp: 47; php: 1
file content (49 lines) | stat: -rw-r--r-- 1,016 bytes parent folder | download | duplicates (8)
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
comment
Shows how to print numbers, so that they can appear in a TeX table.
texprint(x,d); prints the matrix x with d decimal places.
itexprint(x,d); the same for interval matrices.
endcomment

function texprint (x,d=5)
	form="\hfill %0."|printf("%g",d)|"g & ";
	form1="\quad %0."|printf("%g",d)|"g & ";
	filler=printf(form1,1/300000000000);
	n=cols(x); m=rows(x)
	s="\settabs\+ \qquad \quad & ";
	loop 1 to n
		s=s|filler;
	end
	s|"\cr",
	loop 1 to m;
		i=#; s="\+ & ";
		loop 1 to n
			s=s|printf(form,x[i,#]);
		end;
		s|"\cr",
	end;
	return ""
endfunction

function itexprint (x,d=5)
	lform="\hfill [%0."|printf("%g",d)|"g";
	rform=",%0."|printf("%g",d)|"g] & ";
	form1="%0."|printf("%g",d)|"g";
	f=printf(form1,1/30000000000);
	filler="\quad "|f|f|" & ";
	n=cols(x); m=rows(x)
	s="\settabs\+ \qquad \quad & ";
	loop 1 to n
		s=s|filler;
	end
	s|"\cr",
	loop 1 to m;
		i=#; s="\+ & ";
		loop 1 to n
			s=s|printf(lform,left(x[i,#]))|printf(rform,right(x[i,#]));
		end;
		s|"\cr",
	end;
	return ""
endfunction