2
/*--------------------------------------------------------------------------*/
4
/* inititializes the random file with descriptor "fd" with "nofRows" rows
5
of zero values columns. each row consists of "nofCols" columns.
6
assumes that the file is rewound and empty.
8
returns 1 if successful and 0 for any kind of error. */
12
/*--------------------------------------------------------------------------*/
14
int G__random_d_initialize_0(int fd, int nofRows, int nofCols)
16
struct fileinfo *fcb = &G__.fileinfo[fd];
18
double zeroVal, *zeroValP;
21
xdrs = &fcb->xdrstream; /* xdr stream is initialized to write into */
22
xdr_setpos(xdrs, 0); /* G__.work_buf in 'opencell.c' */
27
for (col = nofCols; col--;)
28
if (!xdr_double(xdrs, zeroValP)) {
30
("G_random_d_initialize_0: xdr_double failed for index %d.\n",
35
for (row = 0; row < nofRows; row++)
36
if (G__write_data(fd, row, nofCols) == -1) {
37
G_warning("G_random_d_initialize_0: write failed in row %d.\n",
45
/*--------------------------------------------------------------------------*/
47
/* inititializes the random file with descriptor "fd" with "nofRows" rows
48
of zero values columns. each row consists of "nofCols" columns.
49
assumes that the file is rewound and empty.
51
returns 1 if successful and 0 for any kind of error. */
54
int G__random_f_initialize_0(int fd, int nofRows, int nofCols)
56
struct fileinfo *fcb = &G__.fileinfo[fd];
58
float zeroVal, *zeroValP;
62
xdrs = &fcb->xdrstream; /* xdr stream is initialized to write into */
63
xdr_setpos(xdrs, 0); /* G__.work_buf in 'opencell.c' */
68
for (col = nofCols; col--;)
69
if (!xdr_float(xdrs, zeroValP)) {
71
("G_random_f_initialize_0: xdr_float failed for index %d.\n",
76
for (row = 0; row < nofRows; row++)
77
if (G__write_data(fd, row, nofCols) == -1) {
78
G_warning("G_random_f_initialize_0: write failed in row %d.\n",
86
/*--------------------------------------------------------------------------*/