00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "G.h"
00010
00011
00012
00013 int
00014 G__random_d_initialize_0 (int fd, int nofRows, int nofCols)
00015
00016 {
00017 struct fileinfo *fcb = &G__.fileinfo[fd];
00018 int row, col;
00019 double zeroVal, *zeroValP;
00020 register XDR* xdrs;
00021
00022 xdrs = &fcb->xdrstream;
00023 xdr_setpos (xdrs, 0);
00024
00025 zeroVal = 0;
00026 zeroValP = &zeroVal;
00027
00028 for (col = nofCols; col--;)
00029 if (! xdr_double (xdrs, zeroValP)) {
00030 G_warning( "G_random_d_initialize_0: xdr_double failed for index %d.\n",
00031 col);
00032 return -1;
00033 }
00034
00035 for (row = 0; row < nofRows; row++)
00036 if (G__write_data (fd, row, nofCols) == -1) {
00037 G_warning( "G_random_d_initialize_0: write failed in row %d.\n", row);
00038 return -1;
00039 }
00040
00041 return 1;
00042 }
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 int
00054 G__random_f_initialize_0 (int fd, int nofRows, int nofCols)
00055
00056 {
00057 struct fileinfo *fcb = &G__.fileinfo[fd];
00058 int row, col;
00059 float zeroVal, *zeroValP;
00060 register XDR* xdrs;
00061
00062
00063 xdrs = &fcb->xdrstream;
00064 xdr_setpos (xdrs, 0);
00065
00066 zeroVal = 0;
00067 zeroValP = &zeroVal;
00068
00069 for (col = nofCols; col--;)
00070 if (! xdr_float (xdrs, zeroValP)) {
00071 G_warning("G_random_f_initialize_0: xdr_float failed for index %d.\n",
00072 col);
00073 return 0;
00074 }
00075
00076 for (row = 0; row < nofRows; row++)
00077 if (G__write_data (fd, row, nofCols) == -1) {
00078 G_warning( "G_random_f_initialize_0: write failed in row %d.\n", row);
00079 return 0;
00080 }
00081
00082 return 1;
00083 }
00084
00085