Mercurial > hg > octave-nkf
changeset 9146:a48c500e48e1
support range->string conversions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 22 Apr 2009 11:05:55 +0200 |
parents | 53364bb317d4 |
children | 5579998f8acf |
files | src/ChangeLog src/ov-range.cc src/ov-range.h |
diffstat | 3 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-04-22 Jaroslav Hajek <highegg@gmail.com> + + * ov-range.cc (octave_range::char_array_value): New virtual function + override. + * ov-range.h: Declare it. + 2009-04-22 Jaroslav Hajek <highegg@gmail.com> * pt-mat.cc (tm_row_const::tm_row_const_rep::do_init_element):
--- a/src/ov-range.cc +++ b/src/ov-range.cc @@ -173,6 +173,20 @@ return retval; } +charNDArray +octave_range::char_array_value (bool) const +{ + const Matrix matrix = range.matrix_value (); + charNDArray retval (dims ()); + + octave_idx_type nel = numel (); + + for (octave_idx_type i = 0; i < nel; i++) + retval.elem (i) = static_cast<char>(matrix.elem (i)); + + return retval; +} + octave_value octave_range::all (int dim) const {
--- a/src/ov-range.h +++ b/src/ov-range.h @@ -181,6 +181,8 @@ FloatNDArray float_array_value (bool = false) const { return FloatMatrix (range.matrix_value ()); } + charNDArray char_array_value (bool = false) const; + // FIXME -- it would be better to have Range::intXNDArray_value // functions to avoid the intermediate conversion to a matrix // object.