next up previous contents
Next: Function: graph_double() Up: GRASP Routines: General purpose Previous: Function: reciprocal()   Contents

Function: graph()

0 void graph(float *array,int n,int spacing)

This is a useful function for debugging. It pops up a graph on the computer screen (using the graphing program xmgr) showing a graph of some array which you happen to want to look at.

The arguments are:

array: Input. The array that you want a graph of.
n: Input. The number of array elements that you want to graph.
spacing: Input. The spacing of the array elements that you want to graph. The elements graphed are array[0], array[spacing], array[2*spacing],...,array[(n-1)*spacing].

This function is a handy way to get a quick look at the contents of some array. It writes the output to a temporary file and then starts up xmgr, reading the input from the file. The $x$ values are evenly spaced integers from $0$ to n-1. The $y$ values are the (subset of) points in array[ ]. If your array contains real data, you might want to use spacing=1. If your array contains complex data (with real and imaginary parts interleaved) you will use spacing=2, and make separate calls to see the real and imaginary parts. For example if complex[0..2047] contains 1024 complex numbers, then:
graph(complex,1024,2) (view 1024 real values)
graph(complex+1,1024,2) (view 1024 imaginary values)

Note that in order not to produce too much garbage on the screen, any output or error messages from xmgr are tossed into /dev/null!

Authors: Bruce Allen, ballen@dirac.phys.uwm.edu
Comments: None.


next up previous contents
Next: Function: graph_double() Up: GRASP Routines: General purpose Previous: Function: reciprocal()   Contents
Bruce Allen 2000-11-19