Mercurial > hg > octave-nkf
changeset 4970:25c2664861bc
[project @ 2004-09-08 05:02:32 by jwe]
author | jwe |
---|---|
date | Wed, 08 Sep 2004 05:02:32 +0000 |
parents | 52f808101130 |
children | 3486c62f2d62 |
files | liboctave/ChangeLog liboctave/data-conv.cc liboctave/data-conv.h src/ChangeLog src/oct-stream.cc src/ov-bool-mat.h src/ov-bool.h src/ov.cc src/ov.h |
diffstat | 9 files changed, 90 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,5 +1,10 @@ 2004-09-07 John W. Eaton <jwe@octave.org> + * data-conv.cc (oct_data_conv::string_to_data_type): Handle dt_logical. + (oct_data_conv::data_type_as_string): Likewise. + + * data-conv.h (oct_data_conv::data_type): Add dt_logical to list. + * Range.cc (round): Delete unused function. * lo-mappers.cc (xround): Rename from round. Change all uses.
--- a/liboctave/data-conv.cc +++ b/liboctave/data-conv.cc @@ -235,6 +235,8 @@ else retval = dt_single; } + else if (s == "logical") + retval = dt_logical; else (*current_liboctave_error_handler) ("invalid data type specified"); @@ -448,6 +450,10 @@ retval = "float"; break; + case oct_data_conv::dt_logical: + retval = "logical"; + break; + case oct_data_conv::dt_unknown: default: retval = "unknown";
--- a/liboctave/data-conv.h +++ b/liboctave/data-conv.h @@ -79,16 +79,17 @@ dt_char = 10, dt_schar = 11, dt_uchar = 12, - dt_short = 13, - dt_ushort = 14, - dt_int = 15, - dt_uint = 16, - dt_long = 17, - dt_ulong = 18, - dt_longlong = 19, - dt_ulonglong = 20, - dt_float = 21, - dt_unknown = 22 // Must be last, have largest value! + dt_logical = 13, + dt_short = 14, + dt_ushort = 15, + dt_int = 16, + dt_uint = 17, + dt_long = 18, + dt_ulong = 19, + dt_longlong = 20, + dt_ulonglong = 21, + dt_float = 22, + dt_unknown = 23 // Must be last, have largest value! }; static data_type string_to_data_type (const std::string& s);
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ +2004-09-08 John W. Eaton <jwe@octave.org> + + * ov.h: Add octave_array_type_traits specialization for + boolNDArray element type. + 2004-09-07 John W. Eaton <jwe@octave.org> + * oct-stream.cc: Instantiate octave_stream::write for Array<bool>. + (octave_stream::read): Expand read_fptr_table to include dt_logical. + + * ov-bool.h (octave_bool::write): New function. + * ov-bool-mat.h (octave_bool_matrix::write): New function. + * ov-fcn-inline.h (octave_fcn_inline::octave_fcn_inline): New copy constructor. (octave_fcn_inline::clone, octave_fcn_inline::empty_clone):
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -2972,17 +2972,17 @@ DO_READ_VAL_TEMPLATE (VAL_T, signed char); \ DO_READ_VAL_TEMPLATE (VAL_T, unsigned char) -INSTANTIATE_DO_READ(int8NDArray); -INSTANTIATE_DO_READ(uint8NDArray); -INSTANTIATE_DO_READ(int16NDArray); -INSTANTIATE_DO_READ(uint16NDArray); -INSTANTIATE_DO_READ(int32NDArray); -INSTANTIATE_DO_READ(uint32NDArray); -INSTANTIATE_DO_READ(int64NDArray); -INSTANTIATE_DO_READ(uint64NDArray); -// INSTANTIATE_DO_READ(floatNDArray); -INSTANTIATE_DO_READ(NDArray); -INSTANTIATE_DO_READ(charNDArray); +INSTANTIATE_DO_READ (int8NDArray); +INSTANTIATE_DO_READ (uint8NDArray); +INSTANTIATE_DO_READ (int16NDArray); +INSTANTIATE_DO_READ (uint16NDArray); +INSTANTIATE_DO_READ (int32NDArray); +INSTANTIATE_DO_READ (uint32NDArray); +INSTANTIATE_DO_READ (int64NDArray); +INSTANTIATE_DO_READ (uint64NDArray); +// INSTANTIATE_DO_READ (floatNDArray); +INSTANTIATE_DO_READ (NDArray); +INSTANTIATE_DO_READ (charNDArray); typedef octave_value (*read_fptr) (octave_stream&, int, int, int, int, bool, oct_mach_info::float_format ffmt, int&); @@ -3003,7 +3003,8 @@ read_fptr_table(R,oct_data_conv::dt_double) = do_read<VAL_T, double>; \ read_fptr_table(R,oct_data_conv::dt_char) = do_read<VAL_T, char>; \ read_fptr_table(R,oct_data_conv::dt_schar) = do_read<VAL_T, signed char>; \ - read_fptr_table(R,oct_data_conv::dt_uchar) = do_read<VAL_T, unsigned char> + read_fptr_table(R,oct_data_conv::dt_uchar) = do_read<VAL_T, unsigned char>; \ + read_fptr_table(R,oct_data_conv::dt_logical) = do_read<VAL_T, unsigned char> octave_value octave_stream::read (const Array<double>& size, int block_size, @@ -3016,7 +3017,7 @@ // Table function pointers for return types x read types. - static Array2<read_fptr> read_fptr_table (oct_data_conv::dt_unknown, 13, 0); + static Array2<read_fptr> read_fptr_table (oct_data_conv::dt_unknown, 14, 0); if (! initialized) { @@ -3032,6 +3033,7 @@ FILL_TABLE_ROW (oct_data_conv::dt_char, charNDArray); FILL_TABLE_ROW (oct_data_conv::dt_schar, charNDArray); FILL_TABLE_ROW (oct_data_conv::dt_uchar, charNDArray); + FILL_TABLE_ROW (oct_data_conv::dt_logical, boolNDArray); initialized = true; } @@ -3311,6 +3313,11 @@ int, oct_mach_info::float_format); template int +octave_stream::write (const Array<bool>&, int, + oct_data_conv::data_type, + int, oct_mach_info::float_format); + +template int octave_stream::write (const Array<double>&, int, oct_data_conv::data_type, int, oct_mach_info::float_format);
--- a/src/ov-bool-mat.h +++ b/src/ov-bool-mat.h @@ -36,6 +36,7 @@ #include "oct-alloc.h" #include "error.h" +#include "oct-stream.h" #include "ov-base.h" #include "ov-base-mat.h" #include "ov-typeinfo.h" @@ -131,6 +132,11 @@ bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); #endif + int write (octave_stream& os, int block_size, + oct_data_conv::data_type output_type, int skip, + oct_mach_info::float_format flt_fmt) const + { return os.write (matrix, block_size, output_type, skip, flt_fmt); } + protected: DECLARE_OCTAVE_ALLOCATOR
--- a/src/ov-bool.h +++ b/src/ov-bool.h @@ -37,6 +37,7 @@ #include "oct-alloc.h" #include "str-vec.h" +#include "oct-stream.h" #include "ov-base.h" #include "ov-base-scalar.h" #include "ov-typeinfo.h" @@ -132,6 +133,14 @@ bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); #endif + int write (octave_stream& os, int block_size, + oct_data_conv::data_type output_type, int skip, + oct_mach_info::float_format flt_fmt) const + { + return os.write (bool_array_value (), block_size, output_type, + skip, flt_fmt); + } + private: DECLARE_OCTAVE_ALLOCATOR
--- a/src/ov.cc +++ b/src/ov.cc @@ -29,8 +29,9 @@ #endif #include "Array-flags.h" +#include "data-conv.h" +#include "quit.h" #include "str-vec.h" -#include "quit.h" #include "oct-obj.h" #include "oct-stream.h" @@ -2158,6 +2159,25 @@ octave_streamoff::register_type (); } +#if 0 +DEFUN (cast, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} cast (@var{val}, @var{type})\n\ +Convert @var{val} to the new data type @var{type}.\n\ +@end deftypefn\n\ +@seealso{class, typeinfo}") +{ + octave_value retval; + + if (args.length () == 2) + error ("cast: not implemented"); + else + print_usage ("cast"); + + return retval; +} +#endif + DEFUN (sizeof, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} sizeof (@var{val})\n\
--- a/src/ov.h +++ b/src/ov.h @@ -1000,6 +1000,7 @@ } OCTAVE_ARRAY_TYPE_TRAIT (charNDArray, char); +OCTAVE_ARRAY_TYPE_TRAIT (boolNDArray, bool); OCTAVE_ARRAY_TYPE_TRAIT (int8NDArray, octave_int8); OCTAVE_ARRAY_TYPE_TRAIT (uint8NDArray, octave_uint8); OCTAVE_ARRAY_TYPE_TRAIT (int16NDArray, octave_int16);