comparison src/DLD-FUNCTIONS/rand.cc @ 4664:19bcdc6a9bb8

[project @ 2003-11-25 06:22:02 by jwe]
author jwe
date Tue, 25 Nov 2003 06:25:00 +0000
parents 7b957b442818
children dece11da64ed
comparison
equal deleted inserted replaced
4663:bf7272f8ba8c 4664:19bcdc6a9bb8
83 else if (s_arg == "normal") 83 else if (s_arg == "normal")
84 { 84 {
85 octave_rand::normal_distribution (); 85 octave_rand::normal_distribution ();
86 } 86 }
87 else 87 else
88 error ("rand: unrecognized string argument"); 88 error ("%s: unrecognized string argument", fcn);
89 } 89 }
90 else if (tmp.is_scalar_type ()) 90 else if (tmp.is_scalar_type ())
91 { 91 {
92 double dval = tmp.double_value (); 92 double dval = tmp.double_value ();
93 93
94 if (xisnan (dval)) 94 if (xisnan (dval))
95 { 95 {
96 error ("rand: NaN is invalid a matrix dimension"); 96 error ("%s: NaN is invalid a matrix dimension", fcn);
97 } 97 }
98 else 98 else
99 { 99 {
100 dims.resize (2); 100 dims.resize (2);
101 101
119 int base = NINT (r.base ()); 119 int base = NINT (r.base ());
120 int incr = NINT (r.inc ()); 120 int incr = NINT (r.inc ());
121 int lim = NINT (r.limit ()); 121 int lim = NINT (r.limit ());
122 122
123 if (base < 0 || lim < 0) 123 if (base < 0 || lim < 0)
124 error ("rand: all dimensions must be nonnegative"); 124 error ("%s: all dimensions must be nonnegative", fcn);
125 else 125 else
126 { 126 {
127 for (int i = 0; i < n; i++) 127 for (int i = 0; i < n; i++)
128 { 128 {
129 dims(i) = base; 129 dims(i) = base;
132 132
133 goto gen_matrix; 133 goto gen_matrix;
134 } 134 }
135 } 135 }
136 else 136 else
137 error ("rand: expecting all elements of range to be integers"); 137 error ("%s: expecting all elements of range to be integers",
138 fcn);
138 } 139 }
139 else if (tmp.is_matrix_type ()) 140 else if (tmp.is_matrix_type ())
140 { 141 {
141 Array<int> iv = tmp.int_vector_value (true); 142 Array<int> iv = tmp.int_vector_value (true);
142 143
150 { 151 {
151 int elt = iv(i); 152 int elt = iv(i);
152 153
153 if (elt < 0) 154 if (elt < 0)
154 { 155 {
155 error ("rand: all dimensions must be nonnegative"); 156 error ("%s: all dimensions must be nonnegative", fcn);
156 goto done; 157 goto done;
157 } 158 }
158 159
159 dims(i) = iv(i); 160 dims(i) = iv(i);
160 } 161 }
161 162
162 goto gen_matrix; 163 goto gen_matrix;
163 } 164 }
164 else 165 else
165 error ("rand: expecting integer vector"); 166 error ("%s: expecting integer vector", fcn);
166 } 167 }
167 else 168 else
168 { 169 {
169 gripe_wrong_type_arg ("rand", tmp); 170 gripe_wrong_type_arg ("rand", tmp);
170 return retval; 171 return retval;
184 185
185 if (! error_state) 186 if (! error_state)
186 octave_rand::seed (d); 187 octave_rand::seed (d);
187 } 188 }
188 else 189 else
189 error ("rand: unrecognized string argument"); 190 error ("%s: unrecognized string argument", fcn);
190 } 191 }
191 else 192 else
192 { 193 {
193 dims.resize (nargin); 194 dims.resize (nargin);
194 195
196 { 197 {
197 dims(i) = args(i).int_value (); 198 dims(i) = args(i).int_value ();
198 199
199 if (error_state) 200 if (error_state)
200 { 201 {
201 error ("rand: expecting integer arguments"); 202 error ("%s: expecting integer arguments", fcn);
202 goto done; 203 goto done;
203 } 204 }
204 } 205 }
205 206
206 goto gen_matrix; 207 goto gen_matrix;