123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- /*--------------------------------------------------------------------------*/
- /* inititializes the random file with descriptor "fd" with "nofRows" rows
- of zero values columns. each row consists of "nofCols" columns.
- assumes that the file is rewound and empty.
- returns 1 if successful and 0 for any kind of error. */
- #include "G.h"
- /*--------------------------------------------------------------------------*/
- int G__random_d_initialize_0(int fd, int nofRows, int nofCols)
- {
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int row, col;
- double zeroVal, *zeroValP;
- register XDR *xdrs;
- xdrs = &fcb->xdrstream; /* xdr stream is initialized to write into */
- xdr_setpos(xdrs, 0); /* G__.work_buf in 'opencell.c' */
- zeroVal = 0;
- zeroValP = &zeroVal;
- for (col = nofCols; col--;)
- if (!xdr_double(xdrs, zeroValP)) {
- G_warning
- ("G_random_d_initialize_0: xdr_double failed for index %d.\n",
- col);
- return -1;
- }
- for (row = 0; row < nofRows; row++)
- if (G__write_data(fd, row, nofCols) == -1) {
- G_warning("G_random_d_initialize_0: write failed in row %d.\n",
- row);
- return -1;
- }
- return 1;
- }
- /*--------------------------------------------------------------------------*/
- /* inititializes the random file with descriptor "fd" with "nofRows" rows
- of zero values columns. each row consists of "nofCols" columns.
- assumes that the file is rewound and empty.
- returns 1 if successful and 0 for any kind of error. */
- int G__random_f_initialize_0(int fd, int nofRows, int nofCols)
- {
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int row, col;
- float zeroVal, *zeroValP;
- register XDR *xdrs;
- xdrs = &fcb->xdrstream; /* xdr stream is initialized to write into */
- xdr_setpos(xdrs, 0); /* G__.work_buf in 'opencell.c' */
- zeroVal = 0;
- zeroValP = &zeroVal;
- for (col = nofCols; col--;)
- if (!xdr_float(xdrs, zeroValP)) {
- G_warning
- ("G_random_f_initialize_0: xdr_float failed for index %d.\n",
- col);
- return 0;
- }
- for (row = 0; row < nofRows; row++)
- if (G__write_data(fd, row, nofCols) == -1) {
- G_warning("G_random_f_initialize_0: write failed in row %d.\n",
- row);
- return 0;
- }
- return 1;
- }
- /*--------------------------------------------------------------------------*/
|