~ubuntu-branches/ubuntu/intrepid/plplot/intrepid

« back to all changes in this revision

Viewing changes to examples/c/x21c.c

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2006-11-04 10:19:34 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061104101934-mlirvdg4gpwi6i5q
Tags: 5.6.1-10
* Orphaning the package
* debian/control: Changed the maintainer to the Debian QA Group

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: x21c.c,v 1.12 2004/01/20 02:25:59 airwin Exp $
 
1
/* $Id: x21c.c,v 1.19 2006/05/27 21:04:07 hbabcock Exp $
2
2
        Grid data demo
3
3
 
4
4
   Copyright (C) 2004  Joao Cardoso
17
17
 
18
18
   You should have received a copy of the GNU Library General Public License
19
19
   along with PLplot; if not, write to the Free Software
20
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
20
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
21
 
22
22
*/
23
23
 
149
149
main(int argc, char *argv[])
150
150
{
151
151
  PLFLT *x, *y, *z, *clev;
152
 
  PLFLT *xg, *yg, **zg, **szg;
 
152
  PLFLT *xg, *yg, **zg;
153
153
  PLFLT zmin, zmax, lzm, lzM;
154
154
  long ct;
155
155
  int i, j, k;
168
168
  xM = yM = 0.8;
169
169
 
170
170
  plMergeOpts(options, "x21c options", NULL);
171
 
  plParseOpts(&argc, argv, PL_PARSE_FULL);
 
171
  plparseopts(&argc, argv, PL_PARSE_FULL);
172
172
 
173
173
  opt[2] = wmin;
174
174
  opt[3] = (PLFLT) knn_order;
209
209
 
210
210
      ct = clock();
211
211
      plgriddata(x, y, z, pts, xg, xp, yg, yp, zg, alg, opt[alg-1]);
212
 
      sprintf(xlab, "time=%d ms", (clock() - ct)/1000);
 
212
      sprintf(xlab, "time=%ld ms", (clock() - ct)/1000);
213
213
      sprintf(ylab, "opt=%.3f", opt[alg-1]);
214
214
 
215
215
      /* - CSA can generate NaNs (only interpolates?!).
302
302
  free_grid(xg, yg);
303
303
  free((void *)clev);
304
304
  plFree2dGrid(zg, xp, yp);
 
305
  exit(0);
305
306
}
306
307
 
307
308
 
329
330
  free((void *)yi);
330
331
}
331
332
 
 
333
/* Function drand48() does not exist on Windows (MSVC/C++) and it is
 
334
   deprecated under Linux, so use rand() instead
 
335
*/
 
336
#define drand48 (1.0/RAND_MAX)*(PLFLT)rand
 
337
 
332
338
void
333
339
create_data(PLFLT **xi, PLFLT **yi, PLFLT **zi, int pts)
334
340
{
347
353
      *x = xt + xm;
348
354
      *y = yt + ym;
349
355
    } else { /* std=1, meaning that many points are outside the plot range */
350
 
      *x = sqrt(-2.*log(xt)) * cos(2.*PI*yt) + xm;
351
 
      *y = sqrt(-2.*log(xt)) * sin(2.*PI*yt) + ym;
 
356
      *x = sqrt(-2.*log(xt)) * cos(2.*M_PI*yt) + xm;
 
357
      *y = sqrt(-2.*log(xt)) * sin(2.*M_PI*yt) + ym;
352
358
    }
353
359
    if (!rosen) {
354
360
      r = sqrt((*x) * (*x) + (*y) * (*y));
355
 
      *z = exp(-r * r) * cos(2.0 * PI * r);
 
361
      *z = exp(-r * r) * cos(2.0 * M_PI * r);
356
362
    } else {
357
363
      *z = log(pow(1. - *x, 2.) + 100. * pow(*y - pow(*x, 2.), 2.));
358
364
    }