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