/* Demonstration of contour plotting */

#include "plplot.h"

#define NPTS      41

float tr[6] = {0.05, 0.0, -1.0, 0.0, 0.05, -1.0};

main()
{
   int i, j;
   float xx, yy;
   static float clevel[11] = {-1.,-.8,-.6,-.4,-.2,0,.2,.4,.6,.8,1.};
   static float z[NPTS][NPTS], w[NPTS][NPTS];
   static int mark=1500, space=1500;

   for (i=0; i<NPTS; i++) {
     xx = (double)(i-(NPTS/2))/(double)(NPTS/2);
     for (j=0; j<NPTS; j++)  {
       yy = (double)(j-(NPTS/2))/(double)(NPTS/2) - 1.0;
       z[i][j] = xx*xx - yy*yy;
       w[i][j] = 2*xx*yy;
     }
   }
   plstar(1,1);
   plenv(-1.0,1.0,-1.0,1.0,0,0);
   plcol(2);
   plcont(&z[0][0],NPTS,NPTS,1,NPTS,1,NPTS,clevel,11,xform);
   plstyl(1,&mark,&space);
   plcol(3);
   plcont(&w[0][0],NPTS,NPTS,1,NPTS,1,NPTS,clevel,11,xform);
   plcol(1);
   pllab("X Coordinate", "Y Coordinate","Contour Plots of Saddle Points");
   plend();
}
