Mercurial > hg > octave-lyh
comparison liboctave/Array-util.cc @ 10366:e5ae13b8b2c2
improve Array indexing error messages
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 27 Feb 2010 08:37:34 +0100 |
parents | 12884915a8e4 |
children | 9c4daf174387 |
comparison
equal
deleted
inserted
replaced
10365:532802559f39 | 10366:e5ae13b8b2c2 |
---|---|
639 ("%s: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", | 639 ("%s: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", |
640 op, op1_nr, op1_nc, op2_nr, op2_nc); | 640 op, op1_nr, op1_nc, op2_nr, op2_nc); |
641 } | 641 } |
642 | 642 |
643 void | 643 void |
644 gripe_nonconformant (const char *op, dim_vector& op1_dims, | 644 gripe_nonconformant (const char *op, const dim_vector& op1_dims, |
645 dim_vector& op2_dims) | 645 const dim_vector& op2_dims) |
646 { | 646 { |
647 std::string op1_dims_str = op1_dims.str (); | 647 std::string op1_dims_str = op1_dims.str (); |
648 std::string op2_dims_str = op2_dims.str (); | 648 std::string op2_dims_str = op2_dims.str (); |
649 | 649 |
650 (*current_liboctave_error_handler) | 650 (*current_liboctave_error_handler) |
651 ("%s: nonconformant arguments (op1 is %s, op2 is %s)", | 651 ("%s: nonconformant arguments (op1 is %s, op2 is %s)", |
652 op, op1_dims_str.c_str (), op2_dims_str.c_str ()); | 652 op, op1_dims_str.c_str (), op2_dims_str.c_str ()); |
653 } | 653 } |
654 | |
655 void gripe_index_out_of_range (int nd, int dim, | |
656 octave_idx_type idx, octave_idx_type ext) | |
657 { | |
658 switch (nd) | |
659 { | |
660 case 1: | |
661 (*current_liboctave_error_handler) | |
662 ("A(I): index out of bounds; value %d out of bound %d", | |
663 idx, ext); | |
664 break; | |
665 case 2: | |
666 (*current_liboctave_error_handler) | |
667 ("A(I,J): %s index out of bounds; value %d out of bound %d", | |
668 (dim == 1) ? "row" : "column", idx, ext); | |
669 break; | |
670 default: | |
671 (*current_liboctave_error_handler) | |
672 ("A(I,J,...): index to dimension %d out of bounds; value %d out of bound %d", | |
673 dim, idx, ext); | |
674 break; | |
675 } | |
676 } | |
677 | |
678 void gripe_del_index_out_of_range (bool is1d, octave_idx_type idx, | |
679 octave_idx_type ext) | |
680 { | |
681 (*current_liboctave_error_handler) | |
682 ("A(%s) = []: index out of bounds; value %d out of bound %d", | |
683 is1d ? "I" : "..,I,..", idx, ext); | |
684 } |