ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rtrace.c
Revision: 2.72
Committed: Thu Nov 8 00:54:07 2018 UTC (6 years, 5 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.71: +2 -1 lines
Log Message:
Moved findmaterial() from source.c to initotypes.c

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 greg 2.72 static const char RCSid[] = "$Id: rtrace.c,v 2.71 2018/02/13 20:27:19 greg Exp $";
3 greg 1.1 #endif
4     /*
5     * rtrace.c - program and variables for individual ray tracing.
6 greg 2.27 */
7    
8 greg 2.28 #include "copyright.h"
9 greg 1.1
10     /*
11     * Input is in the form:
12     *
13     * xorg yorg zorg xdir ydir zdir
14     *
15     * The direction need not be normalized. Output is flexible.
16 greg 1.7 * If the direction vector is (0,0,0), then the output is flushed.
17 greg 1.1 * All values default to ascii representation of real
18     * numbers. Binary representations can be selected
19     * with '-ff' for float or '-fd' for double. By default,
20 greg 1.13 * radiance is computed. The '-i' or '-I' options indicate that
21 greg 1.1 * irradiance values are desired.
22     */
23 greg 2.32
24     #include <time.h>
25 greg 1.1
26 schorsch 2.30 #include "platform.h"
27 greg 1.1 #include "ray.h"
28 schorsch 2.37 #include "ambient.h"
29     #include "source.h"
30 greg 1.1 #include "otypes.h"
31 greg 2.72 #include "otspecial.h"
32 greg 2.6 #include "resolu.h"
33 schorsch 2.49 #include "random.h"
34 greg 2.6
35 greg 2.57 extern int inform; /* input format */
36     extern int outform; /* output format */
37     extern char *outvals; /* output values */
38 greg 2.27
39 greg 2.57 extern int imm_irrad; /* compute immediate irradiance? */
40     extern int lim_dist; /* limit distance? */
41 greg 1.14
42 greg 2.57 extern char *tralist[]; /* list of modifers to trace (or no) */
43     extern int traincl; /* include == 1, exclude == 0 */
44 greg 1.13
45 greg 2.57 extern int hresolu; /* horizontal resolution */
46     extern int vresolu; /* vertical resolution */
47 greg 1.1
48 greg 2.57 static int castonly = 0;
49 greg 2.55
50 greg 2.46 #ifndef MAXTSET
51 greg 2.55 #define MAXTSET 8191 /* maximum number in trace set */
52 greg 2.46 #endif
53 greg 2.15 OBJECT traset[MAXTSET+1]={0}; /* trace include/exclude set */
54    
55 greg 1.1 static RAY thisray; /* for our convenience */
56    
57 greg 2.65 typedef void putf_t(RREAL *v, int n);
58 schorsch 2.37 static putf_t puta, putd, putf;
59 greg 1.1
60 schorsch 2.37 typedef void oputf_t(RAY *r);
61 greg 2.51 static oputf_t oputo, oputd, oputv, oputV, oputl, oputL, oputc, oputp,
62 greg 2.42 oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputtilde;
63 schorsch 2.37
64     static void setoutput(char *vs);
65 greg 2.57 extern void tranotify(OBJECT obj);
66 schorsch 2.37 static void bogusray(void);
67 greg 2.59 static void raycast(RAY *r);
68     static void rayirrad(RAY *r);
69     static void rtcompute(FVECT org, FVECT dir, double dmax);
70 greg 2.57 static int printvals(RAY *r);
71     static int getvec(FVECT vec, int fmt, FILE *fp);
72     static void tabin(RAY *r);
73     static void ourtrace(RAY *r);
74 greg 1.1
75 schorsch 2.37 static oputf_t *ray_out[16], *every_out[16];
76     static putf_t *putreal;
77 greg 2.27
78 greg 1.1
79 greg 2.27 void
80 schorsch 2.37 quit( /* quit program */
81     int code
82     )
83 greg 1.1 {
84 greg 2.57 if (ray_pnprocs > 0) /* close children if any */
85     ray_pclose(0);
86     #ifndef NON_POSIX
87 greg 2.58 else if (!ray_pnprocs) {
88     headclean(); /* delete header file */
89     pfclean(); /* clean up persist files */
90     }
91 greg 2.11 #endif
92 greg 1.1 exit(code);
93     }
94    
95    
96 greg 2.57 char *
97 schorsch 2.37 formstr( /* return format identifier */
98     int f
99     )
100 greg 2.6 {
101     switch (f) {
102     case 'a': return("ascii");
103     case 'f': return("float");
104     case 'd': return("double");
105     case 'c': return(COLRFMT);
106     }
107     return("unknown");
108     }
109    
110    
111 schorsch 2.37 extern void
112     rtrace( /* trace rays from file */
113 greg 2.59 char *fname,
114     int nproc
115 schorsch 2.37 )
116 greg 1.1 {
117 greg 2.45 unsigned long vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu
118 greg 2.66 : (unsigned long)vresolu;
119 greg 2.64 long nextflush = (vresolu > 0) & (hresolu > 1) ? 0 : hresolu;
120 greg 1.1 FILE *fp;
121 gregl 2.25 double d;
122 greg 1.2 FVECT orig, direc;
123 greg 1.1 /* set up input */
124     if (fname == NULL)
125     fp = stdin;
126     else if ((fp = fopen(fname, "r")) == NULL) {
127     sprintf(errmsg, "cannot open input file \"%s\"", fname);
128     error(SYSTEM, errmsg);
129     }
130 greg 2.8 if (inform != 'a')
131 schorsch 2.30 SET_FILE_BINARY(fp);
132 greg 1.1 /* set up output */
133 greg 2.16 setoutput(outvals);
134 greg 2.59 if (imm_irrad)
135     castonly = 0;
136     else if (castonly)
137     nproc = 1; /* don't bother multiprocessing */
138 greg 1.1 switch (outform) {
139     case 'a': putreal = puta; break;
140     case 'f': putreal = putf; break;
141     case 'd': putreal = putd; break;
142 greg 2.6 case 'c':
143     if (strcmp(outvals, "v"))
144     error(USER, "color format with value output only");
145     break;
146     default:
147     error(CONSISTENCY, "botched output format");
148 greg 1.1 }
149 greg 2.59 if (nproc > 1) { /* start multiprocessing */
150     ray_popen(nproc);
151 greg 2.58 ray_fifo_out = printvals;
152 greg 2.59 }
153 greg 2.12 if (hresolu > 0) {
154     if (vresolu > 0)
155     fprtresolu(hresolu, vresolu, stdout);
156     fflush(stdout);
157     }
158 greg 1.1 /* process file */
159     while (getvec(orig, inform, fp) == 0 &&
160     getvec(direc, inform, fp) == 0) {
161    
162 gregl 2.25 d = normalize(direc);
163     if (d == 0.0) { /* zero ==> flush */
164 greg 2.45 if (--nextflush <= 0 || !vcount) {
165 greg 2.63 if (nproc > 1 && ray_fifo_flush() < 0)
166 greg 2.71 error(USER, "child(ren) died");
167 greg 2.63 bogusray();
168 gregl 2.24 fflush(stdout);
169 greg 2.64 nextflush = (vresolu > 0) & (hresolu > 1) ? 0 :
170     hresolu;
171 greg 2.63 } else
172     bogusray();
173 greg 2.57 } else { /* compute and print */
174 greg 2.59 rtcompute(orig, direc, lim_dist ? d : 0.0);
175 greg 1.7 /* flush if time */
176 greg 2.45 if (!--nextflush) {
177 greg 2.59 if (nproc > 1 && ray_fifo_flush() < 0)
178 greg 2.71 error(USER, "child(ren) died");
179 gregl 2.24 fflush(stdout);
180     nextflush = hresolu;
181     }
182 greg 1.1 }
183     if (ferror(stdout))
184     error(SYSTEM, "write error");
185 greg 2.45 if (vcount && !--vcount) /* check for end */
186 greg 1.1 break;
187     }
188 greg 2.59 if (nproc > 1) { /* clean up children */
189     if (ray_fifo_flush() < 0)
190     error(USER, "unable to complete processing");
191     ray_pclose(0);
192     }
193 greg 2.50 if (fflush(stdout) < 0)
194     error(SYSTEM, "write error");
195 greg 2.45 if (vcount)
196 greg 2.42 error(USER, "unexpected EOF on input");
197 greg 2.12 if (fname != NULL)
198     fclose(fp);
199 greg 1.1 }
200    
201    
202 schorsch 2.37 static void
203 greg 2.40 trace_sources(void) /* trace rays to light sources, also */
204     {
205     int sn;
206    
207     for (sn = 0; sn < nsources; sn++)
208     source[sn].sflags |= SFOLLOW;
209     }
210    
211    
212     static void
213 schorsch 2.37 setoutput( /* set up output tables */
214 greg 2.56 char *vs
215 schorsch 2.37 )
216 greg 1.1 {
217 greg 2.56 oputf_t **table = ray_out;
218 greg 1.1
219 greg 1.11 castonly = 1;
220 greg 1.1 while (*vs)
221     switch (*vs++) {
222 greg 2.40 case 'T': /* trace sources */
223 greg 2.42 if (!*vs) break;
224 greg 2.40 trace_sources();
225     /* fall through */
226 greg 1.1 case 't': /* trace */
227 greg 2.42 if (!*vs) break;
228 greg 1.1 *table = NULL;
229     table = every_out;
230     trace = ourtrace;
231 greg 1.11 castonly = 0;
232 greg 1.1 break;
233     case 'o': /* origin */
234     *table++ = oputo;
235     break;
236     case 'd': /* direction */
237     *table++ = oputd;
238     break;
239     case 'v': /* value */
240     *table++ = oputv;
241 greg 1.11 castonly = 0;
242 greg 1.1 break;
243 greg 2.51 case 'V': /* contribution */
244     *table++ = oputV;
245     if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0))
246     error(WARNING,
247     "-otV accuracy depends on -aa 0 -as 0");
248     break;
249 greg 2.5 case 'l': /* effective distance */
250 greg 1.1 *table++ = oputl;
251 greg 1.11 castonly = 0;
252 greg 1.1 break;
253 greg 2.29 case 'c': /* local coordinates */
254     *table++ = oputc;
255     break;
256 greg 2.5 case 'L': /* single ray length */
257     *table++ = oputL;
258     break;
259 greg 1.1 case 'p': /* point */
260     *table++ = oputp;
261     break;
262 greg 2.9 case 'n': /* perturbed normal */
263 greg 1.1 *table++ = oputn;
264 greg 2.9 castonly = 0;
265 greg 1.1 break;
266 greg 2.9 case 'N': /* unperturbed normal */
267     *table++ = oputN;
268     break;
269 greg 1.1 case 's': /* surface */
270     *table++ = oputs;
271     break;
272     case 'w': /* weight */
273     *table++ = oputw;
274     break;
275 greg 2.40 case 'W': /* coefficient */
276     *table++ = oputW;
277     if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0))
278     error(WARNING,
279 greg 2.41 "-otW accuracy depends on -aa 0 -as 0");
280 greg 2.40 break;
281 greg 1.1 case 'm': /* modifier */
282     *table++ = oputm;
283     break;
284 greg 2.39 case 'M': /* material */
285     *table++ = oputM;
286     break;
287 greg 2.42 case '~': /* tilde */
288     *table++ = oputtilde;
289 greg 2.41 break;
290 greg 1.1 }
291     *table = NULL;
292 gregl 2.24 }
293    
294    
295 schorsch 2.37 static void
296     bogusray(void) /* print out empty record */
297 gregl 2.24 {
298     thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] =
299     thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0;
300 greg 2.40 thisray.rmax = 0.0;
301     rayorigin(&thisray, PRIMARY, NULL, NULL);
302 gregl 2.24 printvals(&thisray);
303 greg 1.1 }
304    
305    
306 schorsch 2.37 static void
307 greg 2.59 raycast( /* compute first ray intersection only */
308     RAY *r
309 schorsch 2.37 )
310 greg 1.1 {
311 greg 2.59 if (!localhit(r, &thescene)) {
312     if (r->ro == &Aftplane) { /* clipped */
313     r->ro = NULL;
314     r->rot = FHUGE;
315     } else
316     sourcehit(r);
317 greg 2.57 }
318 greg 1.1 }
319    
320    
321 schorsch 2.37 static void
322 greg 2.59 rayirrad( /* compute irradiance rather than radiance */
323     RAY *r
324     )
325     {
326 greg 2.62 void (*old_revf)(RAY *) = r->revf;
327    
328 greg 2.59 r->rot = 1e-5; /* pretend we hit surface */
329     VSUM(r->rop, r->rorg, r->rdir, r->rot);
330     r->ron[0] = -r->rdir[0];
331     r->ron[1] = -r->rdir[1];
332     r->ron[2] = -r->rdir[2];
333     r->rod = 1.0;
334 greg 2.62 /* compute result */
335 greg 2.61 r->revf = raytrace;
336 greg 2.59 (*ofun[Lamb.otype].funp)(&Lamb, r);
337 greg 2.62 r->revf = old_revf;
338 greg 2.59 }
339    
340    
341     static void
342     rtcompute( /* compute and print ray value(s) */
343 schorsch 2.37 FVECT org,
344 greg 2.59 FVECT dir,
345     double dmax
346 schorsch 2.37 )
347 greg 1.1 {
348 greg 2.60 /* set up ray */
349     rayorigin(&thisray, PRIMARY, NULL, NULL);
350     if (imm_irrad) {
351 greg 2.59 VSUM(thisray.rorg, org, dir, 1.1e-4);
352     thisray.rdir[0] = -dir[0];
353     thisray.rdir[1] = -dir[1];
354     thisray.rdir[2] = -dir[2];
355     thisray.rmax = 0.0;
356 greg 2.60 thisray.revf = rayirrad;
357 greg 2.59 } else {
358     VCOPY(thisray.rorg, org);
359     VCOPY(thisray.rdir, dir);
360     thisray.rmax = dmax;
361 greg 2.60 if (castonly)
362     thisray.revf = raycast;
363 greg 2.59 }
364     if (ray_pnprocs > 1) { /* multiprocessing FIFO? */
365     if (ray_fifo_in(&thisray) < 0)
366     error(USER, "lost children");
367     return;
368     }
369     samplendx++; /* else do it ourselves */
370     rayvalue(&thisray);
371 greg 2.16 printvals(&thisray);
372     }
373    
374    
375 greg 2.57 static int
376 schorsch 2.37 printvals( /* print requested ray values */
377     RAY *r
378     )
379 greg 2.16 {
380 greg 2.56 oputf_t **tp;
381 greg 2.16
382     if (ray_out[0] == NULL)
383 greg 2.57 return(0);
384 greg 2.16 for (tp = ray_out; *tp != NULL; tp++)
385     (**tp)(r);
386 greg 1.1 if (outform == 'a')
387     putchar('\n');
388 greg 2.57 return(1);
389 greg 1.1 }
390    
391    
392 schorsch 2.37 static int
393     getvec( /* get a vector from fp */
394 greg 2.56 FVECT vec,
395 schorsch 2.37 int fmt,
396     FILE *fp
397     )
398 greg 1.1 {
399     static float vf[3];
400 greg 2.5 static double vd[3];
401 greg 1.19 char buf[32];
402 greg 2.56 int i;
403 greg 1.1
404     switch (fmt) {
405     case 'a': /* ascii */
406 greg 1.19 for (i = 0; i < 3; i++) {
407     if (fgetword(buf, sizeof(buf), fp) == NULL ||
408     !isflt(buf))
409     return(-1);
410     vec[i] = atof(buf);
411     }
412 greg 1.1 break;
413     case 'f': /* binary float */
414 greg 2.70 if (getbinary(vf, sizeof(float), 3, fp) != 3)
415 greg 1.1 return(-1);
416 greg 2.58 VCOPY(vec, vf);
417 greg 1.1 break;
418     case 'd': /* binary double */
419 greg 2.70 if (getbinary(vd, sizeof(double), 3, fp) != 3)
420 greg 1.1 return(-1);
421 greg 2.58 VCOPY(vec, vd);
422 greg 1.1 break;
423 greg 2.6 default:
424     error(CONSISTENCY, "botched input format");
425 greg 1.1 }
426     return(0);
427     }
428    
429    
430 greg 2.57 void
431 schorsch 2.37 tranotify( /* record new modifier */
432     OBJECT obj
433     )
434 greg 2.15 {
435     static int hitlimit = 0;
436 greg 2.56 OBJREC *o = objptr(obj);
437     char **tralp;
438 greg 2.15
439 greg 2.27 if (obj == OVOID) { /* starting over */
440     traset[0] = 0;
441     hitlimit = 0;
442     return;
443     }
444 greg 2.15 if (hitlimit || !ismodifier(o->otype))
445     return;
446     for (tralp = tralist; *tralp != NULL; tralp++)
447     if (!strcmp(o->oname, *tralp)) {
448     if (traset[0] >= MAXTSET) {
449     error(WARNING, "too many modifiers in trace list");
450     hitlimit++;
451     return; /* should this be fatal? */
452     }
453     insertelem(traset, obj);
454     return;
455     }
456     }
457    
458    
459 greg 2.27 static void
460 schorsch 2.37 ourtrace( /* print ray values */
461     RAY *r
462     )
463 greg 1.1 {
464 greg 2.56 oputf_t **tp;
465 greg 1.1
466     if (every_out[0] == NULL)
467 greg 2.15 return;
468 greg 2.16 if (r->ro == NULL) {
469     if (traincl == 1)
470     return;
471     } else if (traincl != -1 && traincl != inset(traset, r->ro->omod))
472 greg 1.1 return;
473     tabin(r);
474     for (tp = every_out; *tp != NULL; tp++)
475     (**tp)(r);
476 greg 2.41 if (outform == 'a')
477     putchar('\n');
478 greg 1.1 }
479    
480    
481 greg 2.27 static void
482 schorsch 2.37 tabin( /* tab in appropriate amount */
483     RAY *r
484     )
485 greg 1.1 {
486 greg 2.40 const RAY *rp;
487 greg 1.1
488     for (rp = r->parent; rp != NULL; rp = rp->parent)
489     putchar('\t');
490     }
491    
492    
493 greg 2.27 static void
494 schorsch 2.37 oputo( /* print origin */
495     RAY *r
496     )
497 greg 1.1 {
498 greg 2.65 (*putreal)(r->rorg, 3);
499 greg 1.1 }
500    
501    
502 greg 2.27 static void
503 schorsch 2.37 oputd( /* print direction */
504     RAY *r
505     )
506 greg 1.1 {
507 greg 2.65 (*putreal)(r->rdir, 3);
508 greg 1.1 }
509    
510    
511 greg 2.27 static void
512 schorsch 2.37 oputv( /* print value */
513     RAY *r
514     )
515 greg 1.1 {
516 greg 2.65 RREAL cval[3];
517    
518 greg 2.6 if (outform == 'c') {
519 greg 2.41 COLR cout;
520 greg 2.6 setcolr(cout, colval(r->rcol,RED),
521     colval(r->rcol,GRN),
522     colval(r->rcol,BLU));
523 greg 2.69 putbinary(cout, sizeof(cout), 1, stdout);
524 greg 2.6 return;
525     }
526 greg 2.65 cval[0] = colval(r->rcol,RED);
527     cval[1] = colval(r->rcol,GRN);
528     cval[2] = colval(r->rcol,BLU);
529     (*putreal)(cval, 3);
530 greg 1.1 }
531    
532    
533 greg 2.27 static void
534 greg 2.51 oputV( /* print value contribution */
535     RAY *r
536     )
537     {
538 greg 2.65 RREAL contr[3];
539 greg 2.51
540     raycontrib(contr, r, PRIMARY);
541     multcolor(contr, r->rcol);
542 greg 2.65 (*putreal)(contr, 3);
543 greg 2.51 }
544    
545    
546     static void
547 schorsch 2.37 oputl( /* print effective distance */
548     RAY *r
549     )
550 greg 1.1 {
551 greg 2.65 (*putreal)(&r->rt, 1);
552 greg 2.5 }
553    
554    
555 greg 2.27 static void
556 schorsch 2.37 oputL( /* print single ray length */
557     RAY *r
558     )
559 greg 2.5 {
560 greg 2.65 (*putreal)(&r->rot, 1);
561 greg 1.1 }
562    
563    
564 greg 2.27 static void
565 schorsch 2.37 oputc( /* print local coordinates */
566     RAY *r
567     )
568 greg 2.29 {
569 greg 2.65 (*putreal)(r->uv, 2);
570 greg 2.29 }
571    
572    
573 greg 2.65 static RREAL vdummy[3] = {0.0, 0.0, 0.0};
574    
575    
576 greg 2.29 static void
577 schorsch 2.37 oputp( /* print point */
578     RAY *r
579     )
580 greg 1.1 {
581 greg 2.65 if (r->rot < FHUGE)
582     (*putreal)(r->rop, 3);
583     else
584     (*putreal)(vdummy, 3);
585 greg 1.1 }
586    
587    
588 greg 2.27 static void
589 schorsch 2.37 oputN( /* print unperturbed normal */
590     RAY *r
591     )
592 greg 1.1 {
593 greg 2.65 if (r->rot < FHUGE)
594     (*putreal)(r->ron, 3);
595     else
596     (*putreal)(vdummy, 3);
597 greg 2.9 }
598    
599    
600 greg 2.27 static void
601 schorsch 2.37 oputn( /* print perturbed normal */
602     RAY *r
603     )
604 greg 2.9 {
605     FVECT pnorm;
606    
607     if (r->rot >= FHUGE) {
608 greg 2.65 (*putreal)(vdummy, 3);
609 greg 2.9 return;
610     }
611     raynormal(pnorm, r);
612 greg 2.65 (*putreal)(pnorm, 3);
613 greg 1.1 }
614    
615    
616 greg 2.27 static void
617 schorsch 2.37 oputs( /* print name */
618     RAY *r
619     )
620 greg 1.1 {
621     if (r->ro != NULL)
622     fputs(r->ro->oname, stdout);
623     else
624     putchar('*');
625     putchar('\t');
626     }
627    
628    
629 greg 2.27 static void
630 schorsch 2.37 oputw( /* print weight */
631     RAY *r
632     )
633 greg 1.1 {
634 greg 2.65 RREAL rwt = r->rweight;
635    
636     (*putreal)(&rwt, 1);
637 greg 1.1 }
638    
639    
640 greg 2.27 static void
641 greg 2.51 oputW( /* print coefficient */
642 greg 2.40 RAY *r
643     )
644     {
645 greg 2.65 RREAL contr[3];
646 greg 2.67 /* shadow ray not on source? */
647     if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
648     setcolor(contr, 0.0, 0.0, 0.0);
649     else
650     raycontrib(contr, r, PRIMARY);
651 greg 2.40
652 greg 2.65 (*putreal)(contr, 3);
653 greg 2.40 }
654    
655    
656     static void
657 schorsch 2.37 oputm( /* print modifier */
658     RAY *r
659     )
660 greg 1.1 {
661     if (r->ro != NULL)
662 greg 2.23 if (r->ro->omod != OVOID)
663     fputs(objptr(r->ro->omod)->oname, stdout);
664     else
665     fputs(VOIDID, stdout);
666 greg 1.1 else
667     putchar('*');
668     putchar('\t');
669     }
670    
671    
672 greg 2.27 static void
673 greg 2.39 oputM( /* print material */
674     RAY *r
675     )
676     {
677     OBJREC *mat;
678    
679     if (r->ro != NULL) {
680     if ((mat = findmaterial(r->ro)) != NULL)
681     fputs(mat->oname, stdout);
682     else
683     fputs(VOIDID, stdout);
684     } else
685     putchar('*');
686     putchar('\t');
687     }
688    
689    
690     static void
691 greg 2.42 oputtilde( /* output tilde (spacer) */
692 greg 2.41 RAY *r
693     )
694     {
695 greg 2.42 fputs("~\t", stdout);
696 greg 2.41 }
697    
698    
699     static void
700 greg 2.65 puta( /* print ascii value(s) */
701     RREAL *v, int n
702 schorsch 2.37 )
703 greg 1.1 {
704 greg 2.65 if (n == 3) {
705     printf("%e\t%e\t%e\t", v[0], v[1], v[2]);
706     return;
707     }
708     while (n--)
709     printf("%e\t", *v++);
710 greg 1.1 }
711    
712    
713 greg 2.27 static void
714 greg 2.65 putd(RREAL *v, int n) /* print binary double(s) */
715 greg 1.1 {
716 greg 2.68 #ifdef SMLFLT
717     double da[3];
718     int i;
719    
720     if (n > 3)
721 greg 2.65 error(INTERNAL, "code error in putd()");
722 greg 2.68 for (i = n; i--; )
723     da[i] = v[i];
724 greg 2.69 putbinary(da, sizeof(double), n, stdout);
725 greg 2.68 #else
726 greg 2.69 putbinary(v, sizeof(RREAL), n, stdout);
727 greg 2.68 #endif
728 greg 1.1 }
729    
730    
731 greg 2.27 static void
732 greg 2.65 putf(RREAL *v, int n) /* print binary float(s) */
733 greg 1.1 {
734 greg 2.68 #ifndef SMLFLT
735 greg 2.65 float fa[3];
736     int i;
737 greg 1.1
738 greg 2.65 if (n > 3)
739     error(INTERNAL, "code error in putf()");
740     for (i = n; i--; )
741     fa[i] = v[i];
742 greg 2.69 putbinary(fa, sizeof(float), n, stdout);
743 greg 2.68 #else
744 greg 2.69 putbinary(v, sizeof(RREAL), n, stdout);
745 greg 2.68 #endif
746 greg 1.1 }