Mercurial > octave-nkf
comparison liboctave/CMatrix.cc @ 5956:cdef72fcd206
[project @ 2006-08-22 20:36:56 by jwe]
author | jwe |
---|---|
date | Tue, 22 Aug 2006 20:36:57 +0000 |
parents | 6b9cec830d72 |
children | 85c7dc4afe6b |
comparison
equal
deleted
inserted
replaced
5955:fc46f9c99028 | 5956:cdef72fcd206 |
---|---|
3462 return result; | 3462 return result; |
3463 } | 3463 } |
3464 | 3464 |
3465 // i/o | 3465 // i/o |
3466 | 3466 |
3467 // Used when converting Inf to something that gnuplot can read. | |
3468 | |
3469 #ifndef OCT_RBV | |
3470 #define OCT_RBV DBL_MAX / 100.0 | |
3471 #endif | |
3472 | |
3473 std::ostream& | |
3474 ComplexMatrix::save_ascii (std::ostream& os, bool& infnan_warned, | |
3475 int strip_nan_and_inf) | |
3476 { | |
3477 if (strip_nan_and_inf) | |
3478 { | |
3479 octave_idx_type nr = rows (); | |
3480 octave_idx_type nc = columns (); | |
3481 | |
3482 for (octave_idx_type i = 0; i < nr; i++) | |
3483 { | |
3484 if (strip_nan_and_inf) | |
3485 { | |
3486 for (octave_idx_type j = 0; j < nc; j++) | |
3487 { | |
3488 Complex c = elem (i, j); | |
3489 | |
3490 if (xisnan (c)) | |
3491 { | |
3492 if (strip_nan_and_inf == 1) | |
3493 goto next_row; | |
3494 else if (strip_nan_and_inf == 2) | |
3495 goto next_row_with_newline; | |
3496 } | |
3497 } | |
3498 } | |
3499 | |
3500 for (octave_idx_type j = 0; j < nc; j++) | |
3501 { | |
3502 Complex c = elem (i, j); | |
3503 | |
3504 if (strip_nan_and_inf) | |
3505 { | |
3506 double re = std::real (c); | |
3507 double im = std::imag (c); | |
3508 | |
3509 if (xisinf (re)) | |
3510 re = re > 0 ? OCT_RBV : -OCT_RBV; | |
3511 | |
3512 if (xisinf (im)) | |
3513 im = im > 0 ? OCT_RBV : -OCT_RBV; | |
3514 | |
3515 c = Complex (re, im); | |
3516 } | |
3517 else if (! infnan_warned && (xisnan (c) || xisinf (c))) | |
3518 { | |
3519 (*current_liboctave_warning_handler) | |
3520 ("save: Inf or NaN values may not be reloadable"); | |
3521 | |
3522 infnan_warned = true; | |
3523 } | |
3524 | |
3525 octave_write_complex (os, c); | |
3526 | |
3527 os << " "; | |
3528 } | |
3529 | |
3530 next_row_with_newline: | |
3531 os << "\n"; | |
3532 | |
3533 next_row: | |
3534 continue; | |
3535 } | |
3536 } | |
3537 else | |
3538 os << *this; | |
3539 | |
3540 return os; | |
3541 } | |
3542 | |
3467 std::ostream& | 3543 std::ostream& |
3468 operator << (std::ostream& os, const ComplexMatrix& a) | 3544 operator << (std::ostream& os, const ComplexMatrix& a) |
3469 { | 3545 { |
3470 for (octave_idx_type i = 0; i < a.rows (); i++) | 3546 for (octave_idx_type i = 0; i < a.rows (); i++) |
3471 { | 3547 { |