File: tmc.c

package info (click to toggle)
xmgr 4.1.2-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,544 kB
  • ctags: 6,680
  • sloc: ansic: 79,050; sh: 1,812; makefile: 278; perl: 90; fortran: 66
file content (66 lines) | stat: -rw-r--r-- 2,262 bytes parent folder | download | duplicates (5)
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
/*
 * test of -pipe option
 */
#include <stdio.h>
#include <math.h>

#ifndef M_PI
#define M_PI 3.14
#endif

main(argc, argv)
    int argc;
    char **argv;
{
    int i, j;
    double x, y, t, dt;

    for (j = 20; j > 0; j--) {

	/*
	 * write out a set
	 */
	for (i = 0; i < 101; i++) {
	    t = 8.0 * i / (1.0 * j) * M_PI;
	    printf("%d %lf\n", i, cos(t) + sin(2.0 * t) + cos(t / 2.0) + sin(4 * t) + cos(t / 4.0));
	}

	printf("&\n");		/* end of set marker */

	/*
	 * if this is the first set (j == 10) then autoscale.
	 */
	if (j == 20) {
	    printf("@view 0.1, 0.1, 0.9, 0.4\n"); /* set the viewport for this graph */
	    printf("@with g1\n");		/* reset the current graph to graph 1 */
	    printf("@view 0.1, 0.5, 0.9, 0.9\n"); /* set the viewport for graph 1 */
	    printf("@with g0\n");		/* reset the current graph to graph 0 */
	    printf("@autoscale\n"); 		/* autoscale the first time through */
	    printf("@focus off\n"); 		/* turn of the focus markers (annoying) */
	    printf("@dft(s0, 2)\n"); 		/* compute the spectrum of the first set */
	    printf("@move g0.s1 to g1.s0\n"); 	/* move the computed spectrum to graph 1 */
	    printf("@with g1\n");		/* set the focus on graph 1 */
	    printf("@autoscale\n");		/* autoscale graph 1 */
	    printf("@subtitle \"Spectrum\"\n"); /* set the subtitle */
	    printf("@with g0\n");		/* reset the current graph to graph 0 */
	    printf("@subtitle \"Data %d\"\n", j);/* set the subtitle for graph 0 */
	    printf("@kill s0\n");		/* don't need it so kill it (data will be read into
						   this set */
	    printf("@sleep 2\n");
	}
	/*
	 * else just redraw the plot
	 */
	else {
	    printf("@dft(s0, 2)\n"); 		/* spectrum */
	    printf("@move g0.s1 to g1.s0\n"); 	/* move it to graph 1 */
	    printf("@subtitle \"Data %d\"\n", j);/* set the subtitle for graph 0 */
	    printf("@redraw\n"); 		/* redraw the graph with the same scaling limits */
	    printf("@kill s0\n"); 		/* kill set 0 in graph 0 */
	    printf("@with g1\n"); 		/* switch to graph 1 */
	    printf("@kill s0\n"); 		/* kill set 0 in graph 1 */
	    printf("@with g0\n"); 		/* reset the current graph to graph 0 */
	    printf("@sleep 1\n");		/* let the graph sit for a sec */
	}			/* end if-else */
    }				/* end for */
}