Mercurial > octave-nkf
comparison liboctave/dNDArray.cc @ 4687:e95c86d48732
[project @ 2004-01-06 21:53:34 by jwe]
author | jwe |
---|---|
date | Tue, 06 Jan 2004 21:53:34 +0000 |
parents | 79fe96966ca0 |
children | a308566c8b42 |
comparison
equal
deleted
inserted
replaced
4686:c7ae43dfdea4 | 4687:e95c86d48732 |
---|---|
284 const dim_vector& dimensions) | 284 const dim_vector& dimensions) |
285 { | 285 { |
286 return ::compute_index (ra_idx, dimensions); | 286 return ::compute_index (ra_idx, dimensions); |
287 } | 287 } |
288 | 288 |
289 // This contains no information on the array structure !!! | |
290 std::ostream& | |
291 operator << (std::ostream& os, const NDArray& a) | |
292 { | |
293 int nel = a.nelem (); | |
294 | |
295 for (int i = 0; i < nel; i++) | |
296 { | |
297 os << " "; | |
298 octave_write_double (os, a.elem (i)); | |
299 os << "\n"; | |
300 } | |
301 return os; | |
302 } | |
303 | |
304 std::istream& | |
305 operator >> (std::istream& is, NDArray& a) | |
306 { | |
307 int nel = a.nelem (); | |
308 | |
309 if (nel < 1 ) | |
310 is.clear (std::ios::badbit); | |
311 else | |
312 { | |
313 double tmp; | |
314 for (int i = 0; i < nel; i++) | |
315 { | |
316 tmp = octave_read_double (is); | |
317 if (is) | |
318 a.elem (i) = tmp; | |
319 else | |
320 goto done; | |
321 } | |
322 } | |
323 | |
324 done: | |
325 | |
326 return is; | |
327 } | |
328 | |
289 NDS_CMP_OPS(NDArray, , double, ) | 329 NDS_CMP_OPS(NDArray, , double, ) |
290 NDS_BOOL_OPS(NDArray, double, 0.0) | 330 NDS_BOOL_OPS(NDArray, double, 0.0) |
291 | 331 |
292 SND_CMP_OPS(double, , NDArray, ) | 332 SND_CMP_OPS(double, , NDArray, ) |
293 SND_BOOL_OPS(double, NDArray, 0.0) | 333 SND_BOOL_OPS(double, NDArray, 0.0) |