# HG changeset patch # User John W. Eaton # Date 1471240889 14400 # Node ID 8b18f46f642754504f580d54069a9937d87fc3a0 # Parent 12f1d273d22a7293cc8399224e746f48353817ca revamp double, single, int type conversions * ov-type-conv.h: Delete. * libinterp/octave-value/module.mk: Update. * op-double-conv.cc, op-float-conv.cc, op-int-conv.cc: Delete. * libinterp/operators/module.mk: Update. * ov.h, ov.cc, ov-base.h, ov-base.cc (octave_value::as_double, octave_value::as_single, octave_value:as_int8, octave_value:as_int16, octave_value:as_int32, octave_value:as_int64, octave_value:as_uint8, octave_value:as_uint16, octave_value:as_uint32, octave_value:as_uint64): New functions. * ov.cc (Fdouble, Fsingle, Fint8, Fint16, Fint32, Fint64, Fuint8, Fuint16, Fuint32, Fuint64): Move here. Simply call as_double, as_single, etc. member functions. * ov-base-int.cc, ov-base-int.h, ov-base-scalar.cc, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-ch-mat.cc, ov-ch-mat.h, ov-complex.cc, ov-complex.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc: Define as_double, as_single, etc. member functions as appropriate. * ov-typeinfo.h, ov-typeinfo.cc (octave_value_typeinfo::type_conv_ops): Delete data member. Remove all uses. (octave_value_typeinfo::register_type_conv_op): Delete. (octave_value_typeinfo::do_register_type_conv_op): Delete. (octave_value_typeinfo::do_lookup_type_conv_op): Delete. * ops.h (INSTALL_CONVOP, CONVDECLX, DEFCONVFNX, DEFCONVFNX2, DEFDBLCONVFN, DEFFLTCONVFN, DEFSTRINTCONVFN, DEFSTRDBLCONVFN, DEFSTRFLTCONVFN, DEFCONVFN, DEFCONVFN2): Delete obsolete macros. * op-bm-bm.cc, op-cdm-cdm.cc, op-cm-cm.cc, op-cs-cs.cc, op-dm-dm.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcs-fcs.cc, op-fdm-fdm.cc, op-fm-fm.cc, op-fs-fs.cc, op-m-m.cc, op-pm-pm.cc, op-s-s.cc, op-sbm-sbm.cc: Delete unused type conversion functions. diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/module.mk --- a/libinterp/octave-value/module.mk Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/module.mk Mon Aug 15 02:01:29 2016 -0400 @@ -56,7 +56,6 @@ libinterp/octave-value/ov-scalar.h \ libinterp/octave-value/ov-str-mat.h \ libinterp/octave-value/ov-struct.h \ - libinterp/octave-value/ov-type-conv.h \ libinterp/octave-value/ov-typeinfo.h \ libinterp/octave-value/ov-usr-fcn.h \ libinterp/octave-value/ov.h \ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-base-int.cc --- a/libinterp/octave-value/ov-base-int.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-base-int.cc Mon Aug 15 02:01:29 2016 -0400 @@ -28,6 +28,17 @@ #include #include +#include "dNDArray.h" +#include "fNDArray.h" +#include "int8NDArray.h" +#include "int16NDArray.h" +#include "int32NDArray.h" +#include "int64NDArray.h" +#include "uint8NDArray.h" +#include "uint16NDArray.h" +#include "uint32NDArray.h" +#include "uint64NDArray.h" + #include "lo-ieee.h" #include "lo-utils.h" #include "mx-base.h" @@ -183,6 +194,76 @@ return retval; } +template +octave_value +octave_base_int_matrix::as_double (void) const +{ + return NDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_single (void) const +{ + return FloatNDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_int8 (void) const +{ + return int8NDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_int16 (void) const +{ + return int16NDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_int32 (void) const +{ + return int32NDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_int64 (void) const +{ + return int64NDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_uint8 (void) const +{ + return uint8NDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_uint16 (void) const +{ + return uint16NDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_uint32 (void) const +{ + return uint32NDArray (this->matrix); +} + +template +octave_value +octave_base_int_matrix::as_uint64 (void) const +{ + return uint64NDArray (this->matrix); +} + template bool octave_base_int_matrix::save_ascii (std::ostream& os) @@ -490,6 +571,76 @@ } template +octave_value +octave_base_int_scalar::as_double (void) const +{ + return static_cast (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_single (void) const +{ + return static_cast (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_int8 (void) const +{ + return octave_int8 (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_int16 (void) const +{ + return octave_int16 (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_int32 (void) const +{ + return octave_int32 (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_int64 (void) const +{ + return octave_int64 (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_uint8 (void) const +{ + return octave_uint8 (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_uint16 (void) const +{ + return octave_uint16 (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_uint32 (void) const +{ + return octave_uint32 (this->scalar); +} + +template +octave_value +octave_base_int_scalar::as_uint64 (void) const +{ + return octave_uint64 (this->scalar); +} + +template bool octave_base_int_scalar::save_ascii (std::ostream& os) { diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-base-int.h --- a/libinterp/octave-value/ov-base-int.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-base-int.h Mon Aug 15 02:01:29 2016 -0400 @@ -71,6 +71,19 @@ octave_value convert_to_str_internal (bool, bool, char type) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + bool save_ascii (std::ostream& os); bool load_ascii (std::istream& is); @@ -116,6 +129,19 @@ octave_value convert_to_str_internal (bool, bool, char type) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + bool save_ascii (std::ostream& os); bool load_ascii (std::istream& is); diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-base-scalar.cc --- a/libinterp/octave-value/ov-base-scalar.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-base-scalar.cc Mon Aug 15 02:01:29 2016 -0400 @@ -26,6 +26,8 @@ #include +#include "oct-inttypes.h" + #include "ovl.h" #include "ov-base.h" #include "ov-cx-mat.h" diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-base.cc --- a/libinterp/octave-value/ov-base.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-base.cc Mon Aug 15 02:01:29 2016 -0400 @@ -137,6 +137,66 @@ err_wrong_type_arg ("full: invalid operation for %s type", type_name ()); } +octave_value +octave_base_value::as_double (void) const +{ + err_invalid_conversion (type_name (), "double"); +} + +octave_value +octave_base_value::as_single (void) const +{ + err_invalid_conversion (type_name (), "single"); +} + +octave_value +octave_base_value::as_int8 (void) const +{ + err_invalid_conversion (type_name (), "int8"); +} + +octave_value +octave_base_value::as_int16 (void) const +{ + err_invalid_conversion (type_name (), "int16"); +} + +octave_value +octave_base_value::as_int32 (void) const +{ + err_invalid_conversion (type_name (), "int32"); +} + +octave_value +octave_base_value::as_int64 (void) const +{ + err_invalid_conversion (type_name (), "int64"); +} + +octave_value +octave_base_value::as_uint8 (void) const +{ + err_invalid_conversion (type_name (), "uint8"); +} + +octave_value +octave_base_value::as_uint16 (void) const +{ + err_invalid_conversion (type_name (), "uint16"); +} + +octave_value +octave_base_value::as_uint32 (void) const +{ + err_invalid_conversion (type_name (), "uint32"); +} + +octave_value +octave_base_value::as_uint64 (void) const +{ + err_invalid_conversion (type_name (), "uint64"); +} + Matrix octave_base_value::size (void) { @@ -1352,22 +1412,26 @@ return false; } -CONVDECLX (matrix_conv) +static octave_base_value * +oct_conv_matrix_conv (const octave_base_value&) { return new octave_matrix (); } -CONVDECLX (complex_matrix_conv) +static octave_base_value * +oct_conv_complex_matrix_conv (const octave_base_value&) { return new octave_complex_matrix (); } -CONVDECLX (string_conv) +static octave_base_value * +oct_conv_string_conv (const octave_base_value&) { return new octave_char_matrix_str (); } -CONVDECLX (cell_conv) +static octave_base_value * +oct_conv_cell_conv (const octave_base_value&) { return new octave_cell (); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-base.h --- a/libinterp/octave-value/ov-base.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-base.h Mon Aug 15 02:01:29 2016 -0400 @@ -242,6 +242,19 @@ virtual octave_value full_value (void) const; + virtual octave_value as_double (void) const; + virtual octave_value as_single (void) const; + + virtual octave_value as_int8 (void) const; + virtual octave_value as_int16 (void) const; + virtual octave_value as_int32 (void) const; + virtual octave_value as_int64 (void) const; + + virtual octave_value as_uint8 (void) const; + virtual octave_value as_uint16 (void) const; + virtual octave_value as_uint32 (void) const; + virtual octave_value as_uint64 (void) const; + virtual octave_base_value *try_narrowing_conversion (void) { return 0; } virtual void maybe_economize (void) { } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-bool-mat.cc --- a/libinterp/octave-value/ov-bool-mat.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-bool-mat.cc Mon Aug 15 02:01:29 2016 -0400 @@ -28,6 +28,17 @@ #include #include +#include "dNDArray.h" +#include "fNDArray.h" +#include "int8NDArray.h" +#include "int16NDArray.h" +#include "int32NDArray.h" +#include "int64NDArray.h" +#include "uint8NDArray.h" +#include "uint16NDArray.h" +#include "uint32NDArray.h" +#include "uint64NDArray.h" + #include "lo-ieee.h" #include "mx-base.h" #include "oct-locbuf.h" @@ -166,6 +177,66 @@ return tmp.convert_to_str (pad, force, type); } +octave_value +octave_bool_matrix::as_double (void) const +{ + return NDArray (matrix); +} + +octave_value +octave_bool_matrix::as_single (void) const +{ + return FloatNDArray (matrix); +} + +octave_value +octave_bool_matrix::as_int8 (void) const +{ + return int8NDArray (matrix); +} + +octave_value +octave_bool_matrix::as_int16 (void) const +{ + return int16NDArray (matrix); +} + +octave_value +octave_bool_matrix::as_int32 (void) const +{ + return int32NDArray (matrix); +} + +octave_value +octave_bool_matrix::as_int64 (void) const +{ + return int64NDArray (matrix); +} + +octave_value +octave_bool_matrix::as_uint8 (void) const +{ + return uint8NDArray (matrix); +} + +octave_value +octave_bool_matrix::as_uint16 (void) const +{ + return uint16NDArray (matrix); +} + +octave_value +octave_bool_matrix::as_uint32 (void) const +{ + return uint32NDArray (matrix); +} + +octave_value +octave_bool_matrix::as_uint64 (void) const +{ + return uint64NDArray (matrix); +} + void octave_bool_matrix::print_raw (std::ostream& os, bool pr_as_read_syntax) const diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-bool-mat.h --- a/libinterp/octave-value/ov-bool-mat.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-bool-mat.h Mon Aug 15 02:01:29 2016 -0400 @@ -193,6 +193,19 @@ octave_value convert_to_str_internal (bool pad, bool force, char type) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + // Use matrix_ref here to clear index cache. void invert (void) { matrix_ref ().invert (); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-bool-sparse.cc --- a/libinterp/octave-value/ov-bool-sparse.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-bool-sparse.cc Mon Aug 15 02:01:29 2016 -0400 @@ -204,6 +204,12 @@ return SparseComplexMatrix (this->matrix); } +octave_value +octave_sparse_bool_matrix::as_double (void) const +{ + return SparseMatrix (this->matrix); +} + bool octave_sparse_bool_matrix::save_binary (std::ostream& os, bool&) { diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-bool-sparse.h --- a/libinterp/octave-value/ov-bool-sparse.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-bool-sparse.h Mon Aug 15 02:01:29 2016 -0400 @@ -132,6 +132,8 @@ octave_value convert_to_str_internal (bool pad, bool force, char type) const; + octave_value as_double (void) const; + bool save_binary (std::ostream& os, bool& save_as_floats); bool load_binary (std::istream& is, bool swap, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-bool.cc --- a/libinterp/octave-value/ov-bool.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-bool.cc Mon Aug 15 02:01:29 2016 -0400 @@ -26,6 +26,8 @@ #include +#include "oct-inttypes.h" + #include "mx-base.h" #include "errwarn.h" @@ -89,6 +91,66 @@ } octave_value +octave_bool::as_double (void) const +{ + return static_cast (scalar); +} + +octave_value +octave_bool::as_single (void) const +{ + return static_cast (scalar); +} + +octave_value +octave_bool::as_int8 (void) const +{ + return octave_int8 (scalar); +} + +octave_value +octave_bool::as_int16 (void) const +{ + return octave_int16 (scalar); +} + +octave_value +octave_bool::as_int32 (void) const +{ + return octave_int32 (scalar); +} + +octave_value +octave_bool::as_int64 (void) const +{ + return octave_int64 (scalar); +} + +octave_value +octave_bool::as_uint8 (void) const +{ + return octave_uint8 (scalar); +} + +octave_value +octave_bool::as_uint16 (void) const +{ + return octave_uint16 (scalar); +} + +octave_value +octave_bool::as_uint32 (void) const +{ + return octave_uint32 (scalar); +} + +octave_value +octave_bool::as_uint64 (void) const +{ + return octave_uint64 (scalar); +} + +octave_value octave_bool::resize (const dim_vector& dv, bool fill) const { if (fill) diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-bool.h --- a/libinterp/octave-value/ov-bool.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-bool.h Mon Aug 15 02:01:29 2016 -0400 @@ -207,6 +207,19 @@ boolNDArray bool_array_value (bool = false) const { return boolNDArray (dim_vector (1, 1), scalar); } + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + octave_value resize (const dim_vector& dv, bool fill = false) const; octave_value convert_to_str_internal (bool pad, bool force, char type) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-ch-mat.cc --- a/libinterp/octave-value/ov-ch-mat.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-ch-mat.cc Mon Aug 15 02:01:29 2016 -0400 @@ -28,6 +28,17 @@ #include #include +#include "dNDArray.h" +#include "fNDArray.h" +#include "int8NDArray.h" +#include "int16NDArray.h" +#include "int32NDArray.h" +#include "int64NDArray.h" +#include "uint8NDArray.h" +#include "uint16NDArray.h" +#include "uint32NDArray.h" +#include "uint64NDArray.h" + #include "lo-ieee.h" #include "mx-base.h" @@ -151,6 +162,66 @@ return retval; } +octave_value +octave_char_matrix::as_double (void) const +{ + return NDArray (matrix); +} + +octave_value +octave_char_matrix::as_single (void) const +{ + return FloatNDArray (matrix); +} + +octave_value +octave_char_matrix::as_int8 (void) const +{ + return int8NDArray (matrix); +} + +octave_value +octave_char_matrix::as_int16 (void) const +{ + return int16NDArray (matrix); +} + +octave_value +octave_char_matrix::as_int32 (void) const +{ + return int32NDArray (matrix); +} + +octave_value +octave_char_matrix::as_int64 (void) const +{ + return int64NDArray (matrix); +} + +octave_value +octave_char_matrix::as_uint8 (void) const +{ + return uint8NDArray (matrix); +} + +octave_value +octave_char_matrix::as_uint16 (void) const +{ + return uint16NDArray (matrix); +} + +octave_value +octave_char_matrix::as_uint32 (void) const +{ + return uint32NDArray (matrix); +} + +octave_value +octave_char_matrix::as_uint64 (void) const +{ + return uint64NDArray (matrix); +} + void octave_char_matrix::print_raw (std::ostream& os, bool pr_as_read_syntax) const diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-ch-mat.h --- a/libinterp/octave-value/ov-ch-mat.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-ch-mat.h Mon Aug 15 02:01:29 2016 -0400 @@ -148,6 +148,19 @@ octave_value convert_to_str_internal (bool, bool, char type) const { return octave_value (matrix, type); } + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; // Unsafe. This function exists to support the MEX interface. diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-complex.cc --- a/libinterp/octave-value/ov-complex.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-complex.cc Mon Aug 15 02:01:29 2016 -0400 @@ -287,6 +287,18 @@ } octave_value +octave_complex::as_double (void) const +{ + return scalar; +} + +octave_value +octave_complex::as_single (void) const +{ + return FloatComplex (scalar); +} + +octave_value octave_complex::diag (octave_idx_type m, octave_idx_type n) const { return ComplexDiagMatrix (Array (dim_vector (1, 1), scalar), m, n); diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-complex.h --- a/libinterp/octave-value/ov-complex.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-complex.h Mon Aug 15 02:01:29 2016 -0400 @@ -158,6 +158,9 @@ return boolNDArray (dim_vector (1, 1), scalar != 0.0); } + octave_value as_double (void) const; + octave_value as_single (void) const; + octave_value diag (octave_idx_type m, octave_idx_type n) const; void increment (void) { scalar += 1.0; } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-cx-diag.cc --- a/libinterp/octave-value/ov-cx-diag.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-cx-diag.cc Mon Aug 15 02:01:29 2016 -0400 @@ -137,6 +137,18 @@ } octave_value +octave_complex_diag_matrix::as_double (void) const +{ + return matrix; +} + +octave_value +octave_complex_diag_matrix::as_single (void) const +{ + return FloatComplexDiagMatrix (matrix); +} + +octave_value octave_complex_diag_matrix::map (unary_mapper_t umap) const { switch (umap) diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-cx-diag.h --- a/libinterp/octave-value/ov-cx-diag.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-cx-diag.h Mon Aug 15 02:01:29 2016 -0400 @@ -79,6 +79,9 @@ FloatComplexDiagMatrix float_complex_diag_matrix_value (bool = false) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + bool save_binary (std::ostream& os, bool& save_as_floats); bool load_binary (std::istream& is, bool swap, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-cx-mat.cc --- a/libinterp/octave-value/ov-cx-mat.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-cx-mat.cc Mon Aug 15 02:01:29 2016 -0400 @@ -28,6 +28,9 @@ #include #include +#include "dNDArray.h" +#include "fNDArray.h" + #include "data-conv.h" #include "lo-ieee.h" #include "lo-specfun.h" @@ -288,6 +291,18 @@ } octave_value +octave_complex_matrix::as_double (void) const +{ + return matrix; +} + +octave_value +octave_complex_matrix::as_single (void) const +{ + return FloatComplexNDArray (matrix); +} + +octave_value octave_complex_matrix::diag (octave_idx_type k) const { octave_value retval; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-cx-mat.h --- a/libinterp/octave-value/ov-cx-mat.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-cx-mat.h Mon Aug 15 02:01:29 2016 -0400 @@ -138,6 +138,9 @@ SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + octave_value diag (octave_idx_type k = 0) const; octave_value diag (octave_idx_type m, octave_idx_type n) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-cx-sparse.cc --- a/libinterp/octave-value/ov-cx-sparse.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-cx-sparse.cc Mon Aug 15 02:01:29 2016 -0400 @@ -221,6 +221,12 @@ return mx_el_ne (matrix, Complex (0.0)); } +octave_value +octave_sparse_complex_matrix::as_double (void) const +{ + return this->matrix; +} + bool octave_sparse_complex_matrix::save_binary (std::ostream& os, bool& save_as_floats) diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-cx-sparse.h --- a/libinterp/octave-value/ov-cx-sparse.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-cx-sparse.h Mon Aug 15 02:01:29 2016 -0400 @@ -127,6 +127,8 @@ SparseBoolMatrix sparse_bool_matrix_value (bool warn = false) const; + octave_value as_double (void) const; + #if 0 int write (octave_stream& os, int block_size, oct_data_conv::data_type output_type, int skip, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-float.cc --- a/libinterp/octave-value/ov-float.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-float.cc Mon Aug 15 02:01:29 2016 -0400 @@ -26,6 +26,8 @@ #include +#include "oct-inttypes.h" + #include "data-conv.h" #include "mach-info.h" #include "lo-specfun.h" @@ -100,6 +102,66 @@ } octave_value +octave_float_scalar::as_double (void) const +{ + return static_cast (scalar); +} + +octave_value +octave_float_scalar::as_single (void) const +{ + return scalar; +} + +octave_value +octave_float_scalar::as_int8 (void) const +{ + return octave_int8 (scalar); +} + +octave_value +octave_float_scalar::as_int16 (void) const +{ + return octave_int16 (scalar); +} + +octave_value +octave_float_scalar::as_int32 (void) const +{ + return octave_int32 (scalar); +} + +octave_value +octave_float_scalar::as_int64 (void) const +{ + return octave_int64 (scalar); +} + +octave_value +octave_float_scalar::as_uint8 (void) const +{ + return octave_uint8 (scalar); +} + +octave_value +octave_float_scalar::as_uint16 (void) const +{ + return octave_uint16 (scalar); +} + +octave_value +octave_float_scalar::as_uint32 (void) const +{ + return octave_uint32 (scalar); +} + +octave_value +octave_float_scalar::as_uint64 (void) const +{ + return octave_uint64 (scalar); +} + +octave_value octave_float_scalar::diag (octave_idx_type m, octave_idx_type n) const { return FloatDiagMatrix (Array (dim_vector (1, 1), scalar), m, n); diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-float.h --- a/libinterp/octave-value/ov-float.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-float.h Mon Aug 15 02:01:29 2016 -0400 @@ -218,6 +218,19 @@ return boolNDArray (dim_vector (1, 1), scalar); } + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + octave_value diag (octave_idx_type m, octave_idx_type n) const; octave_value convert_to_str_internal (bool pad, bool force, char type) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-complex.cc --- a/libinterp/octave-value/ov-flt-complex.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-complex.cc Mon Aug 15 02:01:29 2016 -0400 @@ -235,6 +235,18 @@ } octave_value +octave_float_complex::as_double (void) const +{ + return Complex (scalar); +} + +octave_value +octave_float_complex::as_single (void) const +{ + return scalar; +} + +octave_value octave_float_complex::diag (octave_idx_type m, octave_idx_type n) const { return diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-complex.h --- a/libinterp/octave-value/ov-flt-complex.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-complex.h Mon Aug 15 02:01:29 2016 -0400 @@ -154,6 +154,9 @@ return boolNDArray (dim_vector (1, 1), scalar != 1.0f); } + octave_value as_double (void) const; + octave_value as_single (void) const; + octave_value diag (octave_idx_type m, octave_idx_type n) const; void increment (void) { scalar += 1.0; } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-cx-diag.cc --- a/libinterp/octave-value/ov-flt-cx-diag.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-cx-diag.cc Mon Aug 15 02:01:29 2016 -0400 @@ -118,6 +118,18 @@ } octave_value +octave_float_complex_diag_matrix::as_double (void) const +{ + return ComplexDiagMatrix (matrix); +} + +octave_value +octave_float_complex_diag_matrix::as_single (void) const +{ + return matrix; +} + +octave_value octave_float_complex_diag_matrix::map (unary_mapper_t umap) const { switch (umap) diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-cx-diag.h --- a/libinterp/octave-value/ov-flt-cx-diag.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-cx-diag.h Mon Aug 15 02:01:29 2016 -0400 @@ -77,6 +77,9 @@ FloatComplexDiagMatrix float_complex_diag_matrix_value (bool = false) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + bool save_binary (std::ostream& os, bool& save_as_floats); bool load_binary (std::istream& is, bool swap, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-cx-mat.cc --- a/libinterp/octave-value/ov-flt-cx-mat.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-cx-mat.cc Mon Aug 15 02:01:29 2016 -0400 @@ -28,6 +28,9 @@ #include #include +#include "dNDArray.h" +#include "fNDArray.h" + #include "data-conv.h" #include "lo-ieee.h" #include "lo-specfun.h" @@ -262,6 +265,18 @@ } octave_value +octave_float_complex_matrix::as_double (void) const +{ + return ComplexNDArray (matrix); +} + +octave_value +octave_float_complex_matrix::as_single (void) const +{ + return matrix; +} + +octave_value octave_float_complex_matrix::diag (octave_idx_type k) const { octave_value retval; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-cx-mat.h --- a/libinterp/octave-value/ov-flt-cx-mat.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-cx-mat.h Mon Aug 15 02:01:29 2016 -0400 @@ -134,6 +134,9 @@ SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + octave_value diag (octave_idx_type k = 0) const; octave_value diag (octave_idx_type m, octave_idx_type n) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-re-diag.cc --- a/libinterp/octave-value/ov-flt-re-diag.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-re-diag.cc Mon Aug 15 02:01:29 2016 -0400 @@ -89,6 +89,66 @@ } octave_value +octave_float_diag_matrix::as_double (void) const +{ + return DiagMatrix (matrix); +} + +octave_value +octave_float_diag_matrix::as_single (void) const +{ + return matrix; +} + +octave_value +octave_float_diag_matrix::as_int8 (void) const +{ + return int8_array_value (); +} + +octave_value +octave_float_diag_matrix::as_int16 (void) const +{ + return int16_array_value (); +} + +octave_value +octave_float_diag_matrix::as_int32 (void) const +{ + return int32_array_value (); +} + +octave_value +octave_float_diag_matrix::as_int64 (void) const +{ + return int64_array_value (); +} + +octave_value +octave_float_diag_matrix::as_uint8 (void) const +{ + return uint8_array_value (); +} + +octave_value +octave_float_diag_matrix::as_uint16 (void) const +{ + return uint16_array_value (); +} + +octave_value +octave_float_diag_matrix::as_uint32 (void) const +{ + return uint32_array_value (); +} + +octave_value +octave_float_diag_matrix::as_uint64 (void) const +{ + return uint64_array_value (); +} + +octave_value octave_float_diag_matrix::map (unary_mapper_t umap) const { switch (umap) diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-re-diag.h --- a/libinterp/octave-value/ov-flt-re-diag.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-re-diag.h Mon Aug 15 02:01:29 2016 -0400 @@ -77,6 +77,19 @@ FloatComplexDiagMatrix float_complex_diag_matrix_value (bool = false) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + bool save_binary (std::ostream& os, bool& save_as_floats); bool load_binary (std::istream& is, bool swap, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-re-mat.cc --- a/libinterp/octave-value/ov-flt-re-mat.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-re-mat.cc Mon Aug 15 02:01:29 2016 -0400 @@ -29,6 +29,17 @@ #include #include +#include "dNDArray.h" +#include "fNDArray.h" +#include "int8NDArray.h" +#include "int16NDArray.h" +#include "int32NDArray.h" +#include "int64NDArray.h" +#include "uint8NDArray.h" +#include "uint16NDArray.h" +#include "uint32NDArray.h" +#include "uint64NDArray.h" + #include "data-conv.h" #include "lo-ieee.h" #include "lo-utils.h" @@ -239,6 +250,66 @@ } octave_value +octave_float_matrix::as_double (void) const +{ + return NDArray (matrix); +} + +octave_value +octave_float_matrix::as_single (void) const +{ + return FloatNDArray (matrix); +} + +octave_value +octave_float_matrix::as_int8 (void) const +{ + return int8NDArray (matrix); +} + +octave_value +octave_float_matrix::as_int16 (void) const +{ + return int16NDArray (matrix); +} + +octave_value +octave_float_matrix::as_int32 (void) const +{ + return int32NDArray (matrix); +} + +octave_value +octave_float_matrix::as_int64 (void) const +{ + return int64NDArray (matrix); +} + +octave_value +octave_float_matrix::as_uint8 (void) const +{ + return uint8NDArray (matrix); +} + +octave_value +octave_float_matrix::as_uint16 (void) const +{ + return uint16NDArray (matrix); +} + +octave_value +octave_float_matrix::as_uint32 (void) const +{ + return uint32NDArray (matrix); +} + +octave_value +octave_float_matrix::as_uint64 (void) const +{ + return uint64NDArray (matrix); +} + +octave_value octave_float_matrix::diag (octave_idx_type k) const { octave_value retval; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-flt-re-mat.h --- a/libinterp/octave-value/ov-flt-re-mat.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-flt-re-mat.h Mon Aug 15 02:01:29 2016 -0400 @@ -167,6 +167,19 @@ SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + octave_value diag (octave_idx_type k = 0) const; octave_value diag (octave_idx_type m, octave_idx_type n) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-int16.cc --- a/libinterp/octave-value/ov-int16.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-int16.cc Mon Aug 15 02:01:29 2016 -0400 @@ -32,9 +32,7 @@ #include "mx-base.h" #include "quit.h" -#include "defun.h" #include "errwarn.h" -#include "ovl.h" #include "oct-lvalue.h" #include "oct-hdf5.h" #include "ops.h" @@ -47,7 +45,6 @@ #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-int16.h" -#include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -74,22 +71,3 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int16_scalar, "int16 scalar", "int16"); - -DEFUN (int16, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} int16 (@var{x}) -Convert @var{x} to 16-bit integer type. -@seealso{int8, uint8, uint16, int32, uint32, int64, uint64} -@end deftypefn */) -{ - OCTAVE_TYPE_CONV_BODY (int16); -} - -/* -%!assert (class (int16 (1)), "int16") -%!assert (int16 (1.25), int16 (1)) -%!assert (int16 (1.5), int16 (2)) -%!assert (int16 (-1.5), int16 (-2)) -%!assert (int16 (2^17), int16 (2^16-1)) -%!assert (int16 (-2^17), int16 (-2^16)) -*/ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-int32.cc --- a/libinterp/octave-value/ov-int32.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-int32.cc Mon Aug 15 02:01:29 2016 -0400 @@ -32,9 +32,7 @@ #include "mx-base.h" #include "quit.h" -#include "defun.h" #include "errwarn.h" -#include "ovl.h" #include "oct-lvalue.h" #include "oct-hdf5.h" #include "ops.h" @@ -47,7 +45,6 @@ #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-int32.h" -#include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -74,22 +71,3 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int32_scalar, "int32 scalar", "int32"); - -DEFUN (int32, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} int32 (@var{x}) -Convert @var{x} to 32-bit integer type. -@seealso{int8, uint8, int16, uint16, uint32, int64, uint64} -@end deftypefn */) -{ - OCTAVE_TYPE_CONV_BODY (int32); -} - -/* -%!assert (class (int32 (1)), "int32") -%!assert (int32 (1.25), int32 (1)) -%!assert (int32 (1.5), int32 (2)) -%!assert (int32 (-1.5), int32 (-2)) -%!assert (int32 (2^33), int32 (2^32-1)) -%!assert (int32 (-2^33), int32 (-2^32)) -*/ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-int64.cc --- a/libinterp/octave-value/ov-int64.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-int64.cc Mon Aug 15 02:01:29 2016 -0400 @@ -32,9 +32,7 @@ #include "mx-base.h" #include "quit.h" -#include "defun.h" #include "errwarn.h" -#include "ovl.h" #include "oct-lvalue.h" #include "oct-hdf5.h" #include "ops.h" @@ -47,7 +45,6 @@ #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-int64.h" -#include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -74,22 +71,3 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int64_scalar, "int64 scalar", "int64"); - -DEFUN (int64, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} int64 (@var{x}) -Convert @var{x} to 64-bit integer type. -@seealso{int8, uint8, int16, uint16, int32, uint32, uint64} -@end deftypefn */) -{ - OCTAVE_TYPE_CONV_BODY (int64); -} - -/* -%!assert (class (int64 (1)), "int64") -%!assert (int64 (1.25), int64 (1)) -%!assert (int64 (1.5), int64 (2)) -%!assert (int64 (-1.5), int64 (-2)) -%!assert (int64 (2^65), int64 (2^64-1)) -%!assert (int64 (-2^65), int64 (-2^64)) -*/ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-int8.cc --- a/libinterp/octave-value/ov-int8.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-int8.cc Mon Aug 15 02:01:29 2016 -0400 @@ -32,9 +32,7 @@ #include "mx-base.h" #include "quit.h" -#include "defun.h" #include "errwarn.h" -#include "ovl.h" #include "oct-lvalue.h" #include "oct-hdf5.h" #include "ops.h" @@ -47,7 +45,6 @@ #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-int8.h" -#include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -74,22 +71,3 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int8_scalar, "int8 scalar", "int8"); - -DEFUN (int8, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} int8 (@var{x}) -Convert @var{x} to 8-bit integer type. -@seealso{uint8, int16, uint16, int32, uint32, int64, uint64} -@end deftypefn */) -{ - OCTAVE_TYPE_CONV_BODY (int8); -} - -/* -%!assert (class (int8 (1)), "int8") -%!assert (int8 (1.25), int8 (1)) -%!assert (int8 (1.5), int8 (2)) -%!assert (int8 (-1.5), int8 (-2)) -%!assert (int8 (2^9), int8 (2^8-1)) -%!assert (int8 (-2^9), int8 (-2^8)) -*/ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-perm.cc --- a/libinterp/octave-value/ov-perm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-perm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -264,6 +264,66 @@ return to_dense ().convert_to_str_internal (pad, force, type); } +octave_value +octave_perm_matrix::as_double (void) const +{ + return matrix; +} + +octave_value +octave_perm_matrix::as_single (void) const +{ + return float_array_value (); +} + +octave_value +octave_perm_matrix::as_int8 (void) const +{ + return int8_array_value (); +} + +octave_value +octave_perm_matrix::as_int16 (void) const +{ + return int16_array_value (); +} + +octave_value +octave_perm_matrix::as_int32 (void) const +{ + return int32_array_value (); +} + +octave_value +octave_perm_matrix::as_int64 (void) const +{ + return int64_array_value (); +} + +octave_value +octave_perm_matrix::as_uint8 (void) const +{ + return uint8_array_value (); +} + +octave_value +octave_perm_matrix::as_uint16 (void) const +{ + return uint16_array_value (); +} + +octave_value +octave_perm_matrix::as_uint32 (void) const +{ + return uint32_array_value (); +} + +octave_value +octave_perm_matrix::as_uint64 (void) const +{ + return uint64_array_value (); +} + bool octave_perm_matrix::save_ascii (std::ostream& os) { diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-perm.h --- a/libinterp/octave-value/ov-perm.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-perm.h Mon Aug 15 02:01:29 2016 -0400 @@ -194,6 +194,19 @@ octave_value convert_to_str_internal (bool pad, bool force, char type) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; bool save_ascii (std::ostream& os); diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-range.cc --- a/libinterp/octave-value/ov-range.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-range.cc Mon Aug 15 02:01:29 2016 -0400 @@ -26,6 +26,17 @@ #include +#include "dNDArray.h" +#include "fNDArray.h" +#include "int8NDArray.h" +#include "int16NDArray.h" +#include "int32NDArray.h" +#include "int64NDArray.h" +#include "uint8NDArray.h" +#include "uint16NDArray.h" +#include "uint32NDArray.h" +#include "uint64NDArray.h" + #include "lo-ieee.h" #include "lo-utils.h" @@ -372,6 +383,66 @@ return tmp.convert_to_str (pad, force, type); } +octave_value +octave_range::as_double (void) const +{ + return range; +} + +octave_value +octave_range::as_single (void) const +{ + return FloatMatrix (range.matrix_value ()); +} + +octave_value +octave_range::as_int8 (void) const +{ + return int8NDArray (range.matrix_value ()); +} + +octave_value +octave_range::as_int16 (void) const +{ + return int16NDArray (range.matrix_value ()); +} + +octave_value +octave_range::as_int32 (void) const +{ + return int32NDArray (range.matrix_value ()); +} + +octave_value +octave_range::as_int64 (void) const +{ + return int64NDArray (range.matrix_value ()); +} + +octave_value +octave_range::as_uint8 (void) const +{ + return uint8NDArray (range.matrix_value ()); +} + +octave_value +octave_range::as_uint16 (void) const +{ + return uint16NDArray (range.matrix_value ()); +} + +octave_value +octave_range::as_uint32 (void) const +{ + return uint32NDArray (range.matrix_value ()); +} + +octave_value +octave_range::as_uint64 (void) const +{ + return uint64NDArray (range.matrix_value ()); +} + void octave_range::print (std::ostream& os, bool pr_as_read_syntax) { diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-range.h --- a/libinterp/octave-value/ov-range.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-range.h Mon Aug 15 02:01:29 2016 -0400 @@ -249,6 +249,19 @@ octave_value convert_to_str_internal (bool pad, bool force, char type) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + void print (std::ostream& os, bool pr_as_read_syntax = false); void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-re-diag.cc --- a/libinterp/octave-value/ov-re-diag.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-re-diag.cc Mon Aug 15 02:01:29 2016 -0400 @@ -158,6 +158,66 @@ } octave_value +octave_diag_matrix::as_double (void) const +{ + return matrix; +} + +octave_value +octave_diag_matrix::as_single (void) const +{ + return FloatDiagMatrix (matrix); +} + +octave_value +octave_diag_matrix::as_int8 (void) const +{ + return int8_array_value (); +} + +octave_value +octave_diag_matrix::as_int16 (void) const +{ + return int16_array_value (); +} + +octave_value +octave_diag_matrix::as_int32 (void) const +{ + return int32_array_value (); +} + +octave_value +octave_diag_matrix::as_int64 (void) const +{ + return int64_array_value (); +} + +octave_value +octave_diag_matrix::as_uint8 (void) const +{ + return uint8_array_value (); +} + +octave_value +octave_diag_matrix::as_uint16 (void) const +{ + return uint16_array_value (); +} + +octave_value +octave_diag_matrix::as_uint32 (void) const +{ + return uint32_array_value (); +} + +octave_value +octave_diag_matrix::as_uint64 (void) const +{ + return uint64_array_value (); +} + +octave_value octave_diag_matrix::map (unary_mapper_t umap) const { switch (umap) diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-re-diag.h --- a/libinterp/octave-value/ov-re-diag.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-re-diag.h Mon Aug 15 02:01:29 2016 -0400 @@ -82,6 +82,19 @@ FloatComplexDiagMatrix float_complex_diag_matrix_value (bool = false) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + bool save_binary (std::ostream& os, bool& save_as_floats); bool load_binary (std::istream& is, bool swap, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-re-mat.cc --- a/libinterp/octave-value/ov-re-mat.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-re-mat.cc Mon Aug 15 02:01:29 2016 -0400 @@ -29,6 +29,17 @@ #include #include +#include "dNDArray.h" +#include "fNDArray.h" +#include "int8NDArray.h" +#include "int16NDArray.h" +#include "int32NDArray.h" +#include "int64NDArray.h" +#include "uint8NDArray.h" +#include "uint16NDArray.h" +#include "uint32NDArray.h" +#include "uint64NDArray.h" + #include "data-conv.h" #include "lo-ieee.h" #include "lo-utils.h" @@ -248,6 +259,66 @@ } octave_value +octave_matrix::as_double (void) const +{ + return NDArray (matrix); +} + +octave_value +octave_matrix::as_single (void) const +{ + return FloatNDArray (matrix); +} + +octave_value +octave_matrix::as_int8 (void) const +{ + return int8NDArray (matrix); +} + +octave_value +octave_matrix::as_int16 (void) const +{ + return int16NDArray (matrix); +} + +octave_value +octave_matrix::as_int32 (void) const +{ + return int32NDArray (matrix); +} + +octave_value +octave_matrix::as_int64 (void) const +{ + return int64NDArray (matrix); +} + +octave_value +octave_matrix::as_uint8 (void) const +{ + return uint8NDArray (matrix); +} + +octave_value +octave_matrix::as_uint16 (void) const +{ + return uint16NDArray (matrix); +} + +octave_value +octave_matrix::as_uint32 (void) const +{ + return uint32NDArray (matrix); +} + +octave_value +octave_matrix::as_uint64 (void) const +{ + return uint64NDArray (matrix); +} + +octave_value octave_matrix::diag (octave_idx_type k) const { octave_value retval; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-re-mat.h --- a/libinterp/octave-value/ov-re-mat.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-re-mat.h Mon Aug 15 02:01:29 2016 -0400 @@ -177,6 +177,19 @@ SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + octave_value diag (octave_idx_type k = 0) const; octave_value diag (octave_idx_type m, octave_idx_type n) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-re-sparse.cc --- a/libinterp/octave-value/ov-re-sparse.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-re-sparse.cc Mon Aug 15 02:01:29 2016 -0400 @@ -246,6 +246,12 @@ return retval; } +octave_value +octave_sparse_matrix::as_double (void) const +{ + return this->matrix; +} + bool octave_sparse_matrix::save_binary (std::ostream& os, bool& save_as_floats) { diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-re-sparse.h --- a/libinterp/octave-value/ov-re-sparse.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-re-sparse.h Mon Aug 15 02:01:29 2016 -0400 @@ -134,6 +134,8 @@ octave_value convert_to_str_internal (bool pad, bool force, char type) const; + octave_value as_double (void) const; + #if 0 int write (octave_stream& os, int block_size, oct_data_conv::data_type output_type, int skip, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-scalar.cc --- a/libinterp/octave-value/ov-scalar.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-scalar.cc Mon Aug 15 02:01:29 2016 -0400 @@ -26,6 +26,8 @@ #include +#include "oct-inttypes.h" + #include "data-conv.h" #include "mach-info.h" #include "lo-specfun.h" @@ -119,6 +121,66 @@ } octave_value +octave_scalar::as_double (void) const +{ + return scalar; +} + +octave_value +octave_scalar::as_single (void) const +{ + return static_cast (scalar); +} + +octave_value +octave_scalar::as_int8 (void) const +{ + return octave_int8 (scalar); +} + +octave_value +octave_scalar::as_int16 (void) const +{ + return octave_int16 (scalar); +} + +octave_value +octave_scalar::as_int32 (void) const +{ + return octave_int32 (scalar); +} + +octave_value +octave_scalar::as_int64 (void) const +{ + return octave_int64 (scalar); +} + +octave_value +octave_scalar::as_uint8 (void) const +{ + return octave_uint8 (scalar); +} + +octave_value +octave_scalar::as_uint16 (void) const +{ + return octave_uint16 (scalar); +} + +octave_value +octave_scalar::as_uint32 (void) const +{ + return octave_uint32 (scalar); +} + +octave_value +octave_scalar::as_uint64 (void) const +{ + return octave_uint64 (scalar); +} + +octave_value octave_scalar::diag (octave_idx_type m, octave_idx_type n) const { return DiagMatrix (Array (dim_vector (1, 1), scalar), m, n); diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-scalar.h --- a/libinterp/octave-value/ov-scalar.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-scalar.h Mon Aug 15 02:01:29 2016 -0400 @@ -217,6 +217,19 @@ return boolNDArray (dim_vector (1, 1), scalar); } + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + octave_value diag (octave_idx_type m, octave_idx_type n) const; octave_value convert_to_str_internal (bool pad, bool force, char type) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-type-conv.h --- a/libinterp/octave-value/ov-type-conv.h Sun Aug 14 20:16:09 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* - -Copyright (C) 2004-2015 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#if ! defined (octave_ov_type_conv_h) -#define octave_ov_type_conv_h 1 - -#include "octave-config.h" - -static -octave_value -octave_type_conv_body (const octave_value &arg, const std::string& name, - int t_result) -{ - int t_arg = arg.type_id (); - octave_value retval; - - if (t_arg == t_result || arg.class_name () == name) - { - retval = arg; - } - else - { - octave_base_value::type_conv_fcn cf1 - = octave_value_typeinfo::lookup_type_conv_op (t_arg, t_result); - - if (cf1) - { - octave_base_value *tmp (cf1 (*(arg.internal_rep ()))); - - if (tmp) - { - retval = octave_value (tmp); - - retval.maybe_mutate (); - } - } - else - { - octave_base_value::type_conv_fcn cf2 - = arg.numeric_conversion_function (); - - if (cf2) - { - octave_base_value *tmp (cf2 (*(arg.internal_rep ()))); - - if (tmp) - { - octave_value xarg (tmp); - - retval = octave_type_conv_body (xarg, name, t_result); - } - } - } - } - - return retval; -} - -template -octave_value -octave_type_conv (const octave_value& arg, const char *t_name) -{ - octave_value retval; - - int t_result = MATRIX_RESULT_T::static_type_id (); - - retval = octave_type_conv_body (arg, t_name, t_result); - - if (retval.is_undefined ()) - { - std::string arg_tname = arg.type_name (); - - std::string result_tname = arg.numel () == 1 - ? SCALAR_RESULT_T::static_type_name () - : MATRIX_RESULT_T::static_type_name (); - - err_invalid_conversion (arg_tname, result_tname); - } - - return retval; -} - -#define OCTAVE_TYPE_CONV_BODY(NAME) \ - if (args.length () != 1) \ - print_usage (); \ - \ - return octave_type_conv (args(0), #NAME); - -#endif diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-typeinfo.cc --- a/libinterp/octave-value/ov-typeinfo.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-typeinfo.cc Mon Aug 15 02:01:29 2016 -0400 @@ -160,14 +160,6 @@ } bool -octave_value_typeinfo::register_type_conv_op (int t, int t_result, - octave_base_value::type_conv_fcn f) -{ - return (instance_ok ()) - ? instance->do_register_type_conv_op (t, t_result, f) : false; -} - -bool octave_value_typeinfo::register_widening_op (int t, int t_result, octave_base_value::type_conv_fcn f) { @@ -220,8 +212,6 @@ pref_assign_conv.resize (dim_vector (len, len), -1); - type_conv_ops.resize (dim_vector (len, len), 0); - widening_ops.resize (dim_vector (len, len), 0); } @@ -446,24 +436,6 @@ } bool -octave_value_typeinfo::do_register_type_conv_op - (int t, int t_result, octave_base_value::type_conv_fcn f) -{ - if (lookup_type_conv_op (t, t_result)) - { - std::string t_name = types(t); - std::string t_result_name = types(t_result); - - warning ("overriding type conversion op for '%s' to '%s'", - t_name.c_str (), t_result_name.c_str ()); - } - - type_conv_ops.checkelem (t, t_result) = reinterpret_cast (f); - - return false; -} - -bool octave_value_typeinfo::do_register_widening_op (int t, int t_result, octave_base_value::type_conv_fcn f) { @@ -581,13 +553,6 @@ } octave_base_value::type_conv_fcn -octave_value_typeinfo::do_lookup_type_conv_op (int t, int t_result) -{ - void *f = type_conv_ops.checkelem (t, t_result); - return reinterpret_cast (f); -} - -octave_base_value::type_conv_fcn octave_value_typeinfo::do_lookup_widening_op (int t, int t_result) { void *f = widening_ops.checkelem (t, t_result); @@ -907,7 +872,6 @@ retval.setfield ("assign_ops", assign_ops_map ()); retval.setfield ("assignany_ops", assignany_ops_map ()); retval.setfield ("pref_assign_conv", as_nd_array (pref_assign_conv)); - retval.setfield ("type_conv_ops", as_bool_nd_array (type_conv_ops)); retval.setfield ("widening_ops", as_bool_nd_array (widening_ops)); return retval; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-typeinfo.h --- a/libinterp/octave-value/ov-typeinfo.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-typeinfo.h Mon Aug 15 02:01:29 2016 -0400 @@ -98,9 +98,6 @@ static bool register_pref_assign_conv (int, int, int); static bool - register_type_conv_op (int, int, octave_base_value::type_conv_fcn); - - static bool register_widening_op (int, int, octave_base_value::type_conv_fcn); static octave_value @@ -176,12 +173,6 @@ } static octave_base_value::type_conv_fcn - lookup_type_conv_op (int t, int t_result) - { - return instance->do_lookup_type_conv_op (t, t_result); - } - - static octave_base_value::type_conv_fcn lookup_widening_op (int t, int t_result) { return instance->do_lookup_widening_op (t, t_result); @@ -213,7 +204,6 @@ assign_ops (dim_vector (octave_value::num_assign_ops, init_tab_sz, init_tab_sz), 0), assignany_ops (dim_vector (octave_value::num_assign_ops, init_tab_sz), 0), pref_assign_conv (dim_vector (init_tab_sz, init_tab_sz), -1), - type_conv_ops (dim_vector (init_tab_sz, init_tab_sz), 0), widening_ops (dim_vector (init_tab_sz, init_tab_sz), 0) { } ~octave_value_typeinfo (void) { } @@ -254,8 +244,6 @@ Array pref_assign_conv; - Array type_conv_ops; - Array widening_ops; int do_register_type (const std::string&, const std::string&, @@ -290,8 +278,6 @@ bool do_register_pref_assign_conv (int, int, int); - bool do_register_type_conv_op (int, int, octave_base_value::type_conv_fcn); - bool do_register_widening_op (int, int, octave_base_value::type_conv_fcn); octave_value do_lookup_type (const std::string& nm); @@ -320,8 +306,6 @@ int do_lookup_pref_assign_conv (int, int); - octave_base_value::type_conv_fcn do_lookup_type_conv_op (int, int); - octave_base_value::type_conv_fcn do_lookup_widening_op (int, int); string_vector do_installed_type_names (void) const; diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-uint16.cc --- a/libinterp/octave-value/ov-uint16.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-uint16.cc Mon Aug 15 02:01:29 2016 -0400 @@ -32,7 +32,6 @@ #include "mx-base.h" #include "quit.h" -#include "defun.h" #include "errwarn.h" #include "ovl.h" #include "oct-lvalue.h" @@ -47,7 +46,6 @@ #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-uint16.h" -#include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -74,22 +72,3 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint16_scalar, "uint16 scalar", "uint16"); - -DEFUN (uint16, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} uint16 (@var{x}) -Convert @var{x} to unsigned 16-bit integer type. -@seealso{int8, uint8, int16, int32, uint32, int64, uint64} -@end deftypefn */) -{ - OCTAVE_TYPE_CONV_BODY (uint16); -} - -/* -%!assert (class (uint16 (1)), "uint16") -%!assert (uint16 (1.25), uint16 (1)) -%!assert (uint16 (1.5), uint16 (2)) -%!assert (uint16 (-1.5), uint16 (0)) -%!assert (uint16 (2^17), uint16 (2^16-1)) -%!assert (uint16 (-2^17), uint16 (0)) -*/ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-uint32.cc --- a/libinterp/octave-value/ov-uint32.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-uint32.cc Mon Aug 15 02:01:29 2016 -0400 @@ -32,9 +32,7 @@ #include "mx-base.h" #include "quit.h" -#include "defun.h" #include "errwarn.h" -#include "ovl.h" #include "oct-lvalue.h" #include "oct-hdf5.h" #include "ops.h" @@ -47,7 +45,6 @@ #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-uint32.h" -#include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -74,22 +71,3 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint32_scalar, "uint32 scalar", "uint32"); - -DEFUN (uint32, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} uint32 (@var{x}) -Convert @var{x} to unsigned 32-bit integer type. -@seealso{int8, uint8, int16, uint16, int32, int64, uint64} -@end deftypefn */) -{ - OCTAVE_TYPE_CONV_BODY (uint32); -} - -/* -%!assert (class (uint32 (1)), "uint32") -%!assert (uint32 (1.25), uint32 (1)) -%!assert (uint32 (1.5), uint32 (2)) -%!assert (uint32 (-1.5), uint32 (0)) -%!assert (uint32 (2^33), uint32 (2^32-1)) -%!assert (uint32 (-2^33), uint32 (0)) -*/ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-uint64.cc --- a/libinterp/octave-value/ov-uint64.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-uint64.cc Mon Aug 15 02:01:29 2016 -0400 @@ -32,9 +32,7 @@ #include "mx-base.h" #include "quit.h" -#include "defun.h" #include "errwarn.h" -#include "ovl.h" #include "oct-lvalue.h" #include "oct-hdf5.h" #include "ops.h" @@ -47,7 +45,6 @@ #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-uint64.h" -#include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -74,22 +71,3 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint64_scalar, "uint64 scalar", "uint64"); - -DEFUN (uint64, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} uint64 (@var{x}) -Convert @var{x} to unsigned 64-bit integer type. -@seealso{int8, uint8, int16, uint16, int32, uint32, int64} -@end deftypefn */) -{ - OCTAVE_TYPE_CONV_BODY (uint64); -} - -/* -%!assert (class (uint64 (1)), "uint64") -%!assert (uint64 (1.25), uint64 (1)) -%!assert (uint64 (1.5), uint64 (2)) -%!assert (uint64 (-1.5), uint64 (0)) -%!assert (uint64 (2^65), uint64 (2^64-1)) -%!assert (uint64 (-2^65), uint64 (0)) -*/ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov-uint8.cc --- a/libinterp/octave-value/ov-uint8.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov-uint8.cc Mon Aug 15 02:01:29 2016 -0400 @@ -32,9 +32,7 @@ #include "mx-base.h" #include "quit.h" -#include "defun.h" #include "errwarn.h" -#include "ovl.h" #include "oct-lvalue.h" #include "oct-hdf5.h" #include "ops.h" @@ -47,7 +45,6 @@ #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-uint8.h" -#include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -74,22 +71,3 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint8_scalar, "uint8 scalar", "uint8"); - -DEFUN (uint8, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} uint8 (@var{x}) -Convert @var{x} to unsigned 8-bit integer type. -@seealso{int8, int16, uint16, int32, uint32, int64, uint64} -@end deftypefn */) -{ - OCTAVE_TYPE_CONV_BODY (uint8); -} - -/* -%!assert (class (uint8 (1)), "uint8") -%!assert (uint8 (1.25), uint8 (1)) -%!assert (uint8 (1.5), uint8 (2)) -%!assert (uint8 (-1.5), uint8 (0)) -%!assert (uint8 (2^9), uint8 (2^8-1)) -%!assert (uint8 (-2^9), uint8 (0)) -*/ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov.cc --- a/libinterp/octave-value/ov.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov.cc Mon Aug 15 02:01:29 2016 -0400 @@ -74,7 +74,6 @@ #include "ov-usr-fcn.h" #include "ov-fcn-handle.h" #include "ov-fcn-inline.h" -#include "ov-type-conv.h" #include "ov-typeinfo.h" #include "ov-null-mat.h" #include "ov-lazy-idx.h" @@ -1184,33 +1183,6 @@ } } -octave_value -octave_value::as_double (void) const -{ - if (is_perm_matrix ()) - return octave_type_conv (*this, "double"); - else if (is_diag_matrix ()) - { - if (is_complex_type ()) - return octave_type_conv (*this, "double"); - else - return octave_type_conv (*this, "double"); - } - else if (is_sparse_type ()) - { - if (is_complex_type ()) - return octave_type_conv (*this, "double"); - else - return octave_type_conv (*this, "double"); - } - else if (is_complex_type ()) - return octave_type_conv (*this, "double"); - else - return octave_type_conv (*this, "double"); - - return ovl (); -} - DEFUN (double, args, , doc: /* -*- texinfo -*- @deftypefn {} {} double (@var{x}) @@ -1255,26 +1227,6 @@ %! assert (class (y), "double"); */ -octave_value -octave_value::as_single (void) const -{ - if (is_diag_matrix ()) - { - if (is_complex_type ()) - return octave_type_conv (*this, "single"); - else - return octave_type_conv (*this, "single"); - } - else if (is_sparse_type ()) - error ("single: sparse type does not support single precision"); - else if (is_complex_type ()) - return octave_type_conv (*this, "single"); - else - return octave_type_conv (*this, "single"); - - return octave_value (); -} - DEFUN (single, args, , doc: /* -*- texinfo -*- @deftypefn {} {} single (@var{x}) @@ -1316,7 +1268,183 @@ %! assert (class (y), "single"); */ - octave_value +DEFUN (int8, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} int8 (@var{x}) +Convert @var{x} to 8-bit integer type. +@seealso{uint8, int16, uint16, int32, uint32, int64, uint64} +@end deftypefn */) +{ + if (args.length () != 1) + print_usage (); + + return args(0).as_int8 (); +} + +/* +%!assert (class (int8 (1)), "int8") +%!assert (int8 (1.25), int8 (1)) +%!assert (int8 (1.5), int8 (2)) +%!assert (int8 (-1.5), int8 (-2)) +%!assert (int8 (2^9), int8 (2^8-1)) +%!assert (int8 (-2^9), int8 (-2^8)) +*/ + +DEFUN (int16, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} int16 (@var{x}) +Convert @var{x} to 16-bit integer type. +@seealso{int8, uint8, uint16, int32, uint32, int64, uint64} +@end deftypefn */) +{ + if (args.length () != 1) + print_usage (); + + return args(0).as_int16 (); +} + +/* +%!assert (class (int16 (1)), "int16") +%!assert (int16 (1.25), int16 (1)) +%!assert (int16 (1.5), int16 (2)) +%!assert (int16 (-1.5), int16 (-2)) +%!assert (int16 (2^17), int16 (2^16-1)) +%!assert (int16 (-2^17), int16 (-2^16)) +*/ + +DEFUN (int32, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} int32 (@var{x}) +Convert @var{x} to 32-bit integer type. +@seealso{int8, uint8, int16, uint16, uint32, int64, uint64} +@end deftypefn */) +{ + if (args.length () != 1) + print_usage (); + + return args(0).as_int32 (); +} + +/* +%!assert (class (int32 (1)), "int32") +%!assert (int32 (1.25), int32 (1)) +%!assert (int32 (1.5), int32 (2)) +%!assert (int32 (-1.5), int32 (-2)) +%!assert (int32 (2^33), int32 (2^32-1)) +%!assert (int32 (-2^33), int32 (-2^32)) +*/ + +DEFUN (int64, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} int64 (@var{x}) +Convert @var{x} to 64-bit integer type. +@seealso{int8, uint8, int16, uint16, int32, uint32, uint64} +@end deftypefn */) +{ + if (args.length () != 1) + print_usage (); + + return args(0).as_int64 (); +} + +/* +%!assert (class (int64 (1)), "int64") +%!assert (int64 (1.25), int64 (1)) +%!assert (int64 (1.5), int64 (2)) +%!assert (int64 (-1.5), int64 (-2)) +%!assert (int64 (2^65), int64 (2^64-1)) +%!assert (int64 (-2^65), int64 (-2^64)) +*/ + +DEFUN (uint8, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} uint8 (@var{x}) +Convert @var{x} to unsigned 8-bit integer type. +@seealso{int8, int16, uint16, int32, uint32, int64, uint64} +@end deftypefn */) +{ + if (args.length () != 1) + print_usage (); + + return args(0).as_uint8 (); +} + +/* +%!assert (class (uint8 (1)), "uint8") +%!assert (uint8 (1.25), uint8 (1)) +%!assert (uint8 (1.5), uint8 (2)) +%!assert (uint8 (-1.5), uint8 (0)) +%!assert (uint8 (2^9), uint8 (2^8-1)) +%!assert (uint8 (-2^9), uint8 (0)) +*/ + +DEFUN (uint16, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} uint16 (@var{x}) +Convert @var{x} to unsigned 16-bit integer type. +@seealso{int8, uint8, int16, int32, uint32, int64, uint64} +@end deftypefn */) +{ + if (args.length () != 1) + print_usage (); + + return args(0).as_uint16 (); +} + +/* +%!assert (class (uint16 (1)), "uint16") +%!assert (uint16 (1.25), uint16 (1)) +%!assert (uint16 (1.5), uint16 (2)) +%!assert (uint16 (-1.5), uint16 (0)) +%!assert (uint16 (2^17), uint16 (2^16-1)) +%!assert (uint16 (-2^17), uint16 (0)) +*/ + +DEFUN (uint32, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} uint32 (@var{x}) +Convert @var{x} to unsigned 32-bit integer type. +@seealso{int8, uint8, int16, uint16, int32, int64, uint64} +@end deftypefn */) +{ + if (args.length () != 1) + print_usage (); + + return args(0).as_uint32 (); +} + +/* +%!assert (class (uint32 (1)), "uint32") +%!assert (uint32 (1.25), uint32 (1)) +%!assert (uint32 (1.5), uint32 (2)) +%!assert (uint32 (-1.5), uint32 (0)) +%!assert (uint32 (2^33), uint32 (2^32-1)) +%!assert (uint32 (-2^33), uint32 (0)) +*/ + +DEFUN (uint64, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} uint64 (@var{x}) +Convert @var{x} to unsigned 64-bit integer type. +@seealso{int8, uint8, int16, uint16, int32, uint32, int64} +@end deftypefn */) +{ + if (args.length () != 1) + print_usage (); + + return args(0).as_uint64 (); +} + +/* +%!assert (class (uint64 (1)), "uint64") +%!assert (uint64 (1.25), uint64 (1)) +%!assert (uint64 (1.5), uint64 (2)) +%!assert (uint64 (-1.5), uint64 (0)) +%!assert (uint64 (2^65), uint64 (2^64-1)) +%!assert (uint64 (-2^65), uint64 (0)) +*/ + +octave_value octave_value::single_subsref (const std::string& type, const octave_value_list& idx) { diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/octave-value/ov.h --- a/libinterp/octave-value/ov.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/octave-value/ov.h Mon Aug 15 02:01:29 2016 -0400 @@ -388,8 +388,18 @@ // Type conversions. - octave_value as_double (void) const; - octave_value as_single (void) const; + octave_value as_double (void) const { return rep->as_double (); } + octave_value as_single (void) const { return rep->as_single (); } + + octave_value as_int8 (void) const { return rep->as_int8 (); } + octave_value as_int16 (void) const { return rep->as_int16 (); } + octave_value as_int32 (void) const { return rep->as_int32 (); } + octave_value as_int64 (void) const { return rep->as_int64 (); } + + octave_value as_uint8 (void) const { return rep->as_uint8 (); } + octave_value as_uint16 (void) const { return rep->as_uint16 (); } + octave_value as_uint32 (void) const { return rep->as_uint32 (); } + octave_value as_uint64 (void) const { return rep->as_uint64 (); } octave_base_value *try_narrowing_conversion (void) { return rep->try_narrowing_conversion (); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/module.mk --- a/libinterp/operators/module.mk Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/module.mk Mon Aug 15 02:01:29 2016 -0400 @@ -37,7 +37,6 @@ libinterp/operators/op-dm-s.cc \ libinterp/operators/op-dm-scm.cc \ libinterp/operators/op-dm-sm.cc \ - libinterp/operators/op-double-conv.cc \ libinterp/operators/op-fcdm-fcdm.cc \ libinterp/operators/op-fcdm-fcm.cc \ libinterp/operators/op-fcdm-fcs.cc \ @@ -62,7 +61,6 @@ libinterp/operators/op-fdm-fdm.cc \ libinterp/operators/op-fdm-fm.cc \ libinterp/operators/op-fdm-fs.cc \ - libinterp/operators/op-float-conv.cc \ libinterp/operators/op-fm-fcdm.cc \ libinterp/operators/op-fm-fcm.cc \ libinterp/operators/op-fm-fcs.cc \ @@ -79,7 +77,6 @@ libinterp/operators/op-i64-i64.cc \ libinterp/operators/op-i8-i8.cc \ libinterp/operators/op-int-concat.cc \ - libinterp/operators/op-int-conv.cc \ libinterp/operators/op-m-cdm.cc \ libinterp/operators/op-m-cm.cc \ libinterp/operators/op-m-cs.cc \ diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-bm-bm.cc --- a/libinterp/operators/op-bm-bm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-bm-bm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -122,9 +122,6 @@ return octave_value (); } -DEFCONVFN (matrix_to_bool_matrix, matrix, bool) -DEFCONVFN (scalar_to_bool_matrix, scalar, bool) - void install_bm_bm_ops (void) { @@ -156,9 +153,6 @@ INSTALL_CATOP (octave_bool_matrix, octave_float_matrix, bm_fm); INSTALL_CATOP (octave_float_matrix, octave_bool_matrix, fm_bm); - INSTALL_CONVOP (octave_matrix, octave_bool_matrix, matrix_to_bool_matrix); - INSTALL_CONVOP (octave_scalar, octave_bool_matrix, scalar_to_bool_matrix); - INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_bool_matrix, assign); INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_matrix, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-cdm-cdm.cc --- a/libinterp/operators/op-cdm-cdm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-cdm-cdm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -83,14 +83,6 @@ return new octave_complex_matrix (v.complex_matrix_value ()); } -CONVDECL (complex_diag_matrix_to_float_complex_diag_matrix) -{ - const octave_complex_diag_matrix& v = dynamic_cast (a); - - return - new octave_float_complex_diag_matrix (v.float_complex_diag_matrix_value ()); -} - void install_cdm_cdm_ops (void) { @@ -110,10 +102,6 @@ INSTALL_BINOP (op_ldiv, octave_complex_diag_matrix, octave_complex_diag_matrix, ldiv); - INSTALL_CONVOP (octave_complex_diag_matrix, octave_complex_matrix, - complex_diag_matrix_to_complex_matrix); - INSTALL_CONVOP (octave_complex_diag_matrix, octave_float_complex_diag_matrix, - complex_diag_matrix_to_float_complex_diag_matrix); INSTALL_ASSIGNCONV (octave_complex_diag_matrix, octave_complex_matrix, octave_complex_matrix); INSTALL_WIDENOP (octave_complex_diag_matrix, octave_complex_matrix, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-cm-cm.cc --- a/libinterp/operators/op-cm-cm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-cm-cm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -216,15 +216,6 @@ DEFNDASSIGNOP_FNOP (assign_el_div, complex_matrix, complex_matrix, complex_array, quotient_eq) -CONVDECL (complex_matrix_to_float_complex_matrix) -{ - const octave_complex_matrix& v = dynamic_cast (a); - - return - new octave_float_complex_matrix - (FloatComplexNDArray (v.complex_array_value ())); -} - void install_cm_cm_ops (void) { @@ -295,7 +286,4 @@ assign_el_mul); INSTALL_ASSIGNOP (op_el_div_eq, octave_complex_matrix, octave_complex_matrix, assign_el_div); - - INSTALL_CONVOP (octave_complex_matrix, octave_float_complex_matrix, - complex_matrix_to_float_complex_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-cs-cs.cc --- a/libinterp/operators/op-cs-cs.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-cs-cs.cc Mon Aug 15 02:01:29 2016 -0400 @@ -153,15 +153,6 @@ DEFNDCATOP_FN (cs_cs, complex, complex, complex_array, complex_array, concat) -CONVDECL (complex_to_float_complex) -{ - const octave_complex& v = dynamic_cast (a); - - return new octave_float_complex_matrix (FloatComplexMatrix (1, 1, - static_cast - (v.complex_value ()))); -} - void install_cs_cs_ops (void) { @@ -202,7 +193,4 @@ INSTALL_ASSIGNCONV (octave_complex, octave_null_str, octave_complex_matrix); INSTALL_ASSIGNCONV (octave_complex, octave_null_sq_str, octave_complex_matrix); - - INSTALL_CONVOP (octave_complex, octave_float_complex_matrix, - complex_to_float_complex); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-dm-dm.cc --- a/libinterp/operators/op-dm-dm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-dm-dm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -77,13 +77,6 @@ return new octave_matrix (v.matrix_value ()); } -CONVDECL (diag_matrix_to_float_diag_matrix) -{ - const octave_diag_matrix& v = dynamic_cast (a); - - return new octave_float_diag_matrix (v.float_diag_matrix_value ()); -} - void install_dm_dm_ops (void) { @@ -98,9 +91,6 @@ INSTALL_BINOP (op_div, octave_diag_matrix, octave_diag_matrix, div); INSTALL_BINOP (op_ldiv, octave_diag_matrix, octave_diag_matrix, ldiv); - INSTALL_CONVOP (octave_diag_matrix, octave_matrix, diag_matrix_to_matrix); - INSTALL_CONVOP (octave_diag_matrix, octave_float_diag_matrix, - diag_matrix_to_float_diag_matrix); INSTALL_ASSIGNCONV (octave_diag_matrix, octave_matrix, octave_matrix); INSTALL_WIDENOP (octave_diag_matrix, octave_matrix, diag_matrix_to_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-double-conv.cc --- a/libinterp/operators/op-double-conv.cc Sun Aug 14 20:16:09 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* - -Copyright (C) 2004-2015 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#if defined (HAVE_CONFIG_H) -# include "config.h" -#endif - -#include "errwarn.h" -#include "ovl.h" -#include "ov.h" -#include "ov-int8.h" -#include "ov-int16.h" -#include "ov-int32.h" -#include "ov-int64.h" -#include "ov-uint8.h" -#include "ov-uint16.h" -#include "ov-uint32.h" -#include "ov-uint64.h" -#include "ov-bool.h" -#include "ov-bool-mat.h" -#include "ov-re-sparse.h" -#include "ov-bool-sparse.h" -#include "ov-range.h" -#include "ov-scalar.h" -#include "ov-re-mat.h" -#include "ov-str-mat.h" -#include "ov-typeinfo.h" -#include "ops.h" - -// conversion ops - -DEFDBLCONVFN (int8_matrix_to_double_matrix, int8_matrix, int8_array) -DEFDBLCONVFN (int16_matrix_to_double_matrix, int16_matrix, int16_array) -DEFDBLCONVFN (int32_matrix_to_double_matrix, int32_matrix, int32_array) -DEFDBLCONVFN (int64_matrix_to_double_matrix, int64_matrix, int64_array) - -DEFDBLCONVFN (uint8_matrix_to_double_matrix, uint8_matrix, uint8_array) -DEFDBLCONVFN (uint16_matrix_to_double_matrix, uint16_matrix, uint16_array) -DEFDBLCONVFN (uint32_matrix_to_double_matrix, uint32_matrix, uint32_array) -DEFDBLCONVFN (uint64_matrix_to_double_matrix, uint64_matrix, uint64_array) - -DEFDBLCONVFN (int8_scalar_to_double_matrix, int8_scalar, int8_array) -DEFDBLCONVFN (int16_scalar_to_double_matrix, int16_scalar, int16_array) -DEFDBLCONVFN (int32_scalar_to_double_matrix, int32_scalar, int32_array) -DEFDBLCONVFN (int64_scalar_to_double_matrix, int64_scalar, int64_array) - -DEFDBLCONVFN (uint8_scalar_to_double_matrix, uint8_scalar, uint8_array) -DEFDBLCONVFN (uint16_scalar_to_double_matrix, uint16_scalar, uint16_array) -DEFDBLCONVFN (uint32_scalar_to_double_matrix, uint32_scalar, uint32_array) -DEFDBLCONVFN (uint64_scalar_to_double_matrix, uint64_scalar, uint64_array) - -DEFDBLCONVFN (bool_matrix_to_double_matrix, bool_matrix, bool_array) -DEFDBLCONVFN (bool_scalar_to_double_matrix, bool, bool_array) - -DEFDBLCONVFN (sparse_matrix_to_double_matrix, sparse_matrix, array) -DEFDBLCONVFN (sparse_bool_matrix_to_double_matrix, sparse_bool_matrix, array) - -DEFDBLCONVFN (range_to_double_matrix, range, array) - -DEFSTRDBLCONVFN(char_matrix_str_to_double_matrix, char_matrix_str) -DEFSTRDBLCONVFN(char_matrix_sq_str_to_double_matrix, char_matrix_sq_str) - -DEFDBLCONVFN (double_scalar_to_double_matrix, scalar, array) - -void -install_double_conv_ops (void) -{ - INSTALL_CONVOP (octave_int8_matrix, octave_matrix, - int8_matrix_to_double_matrix); - INSTALL_CONVOP (octave_int16_matrix, octave_matrix, - int16_matrix_to_double_matrix); - INSTALL_CONVOP (octave_int32_matrix, octave_matrix, - int32_matrix_to_double_matrix); - INSTALL_CONVOP (octave_int64_matrix, octave_matrix, - int64_matrix_to_double_matrix); - - INSTALL_CONVOP (octave_uint8_matrix, octave_matrix, - uint8_matrix_to_double_matrix); - INSTALL_CONVOP (octave_uint16_matrix, octave_matrix, - uint16_matrix_to_double_matrix); - INSTALL_CONVOP (octave_uint32_matrix, octave_matrix, - uint32_matrix_to_double_matrix); - INSTALL_CONVOP (octave_uint64_matrix, octave_matrix, - uint64_matrix_to_double_matrix); - - INSTALL_CONVOP (octave_int8_scalar, octave_matrix, - int8_scalar_to_double_matrix); - INSTALL_CONVOP (octave_int16_scalar, octave_matrix, - int16_scalar_to_double_matrix); - INSTALL_CONVOP (octave_int32_scalar, octave_matrix, - int32_scalar_to_double_matrix); - INSTALL_CONVOP (octave_int64_scalar, octave_matrix, - int64_scalar_to_double_matrix); - - INSTALL_CONVOP (octave_uint8_scalar, octave_matrix, - uint8_scalar_to_double_matrix); - INSTALL_CONVOP (octave_uint16_scalar, octave_matrix, - uint16_scalar_to_double_matrix); - INSTALL_CONVOP (octave_uint32_scalar, octave_matrix, - uint32_scalar_to_double_matrix); - INSTALL_CONVOP (octave_uint64_scalar, octave_matrix, - uint64_scalar_to_double_matrix); - - INSTALL_CONVOP (octave_bool_matrix, octave_matrix, - bool_matrix_to_double_matrix); - INSTALL_CONVOP (octave_bool, octave_matrix, bool_scalar_to_double_matrix); - - INSTALL_CONVOP (octave_sparse_matrix, octave_matrix, - sparse_matrix_to_double_matrix); - INSTALL_CONVOP (octave_sparse_bool_matrix, octave_matrix, - sparse_bool_matrix_to_double_matrix); - - INSTALL_CONVOP (octave_range, octave_matrix, range_to_double_matrix); - - INSTALL_CONVOP (octave_char_matrix_str, octave_matrix, - char_matrix_str_to_double_matrix); - INSTALL_CONVOP (octave_char_matrix_sq_str, octave_matrix, - char_matrix_sq_str_to_double_matrix); - - INSTALL_CONVOP (octave_scalar, octave_matrix, double_scalar_to_double_matrix); -} diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-fcdm-fcdm.cc --- a/libinterp/operators/op-fcdm-fcdm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-fcdm-fcdm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -76,13 +76,6 @@ v2.float_complex_diag_matrix_value ()); } -CONVDECL (float_complex_diag_matrix_to_float_complex_matrix) -{ - const octave_float_complex_diag_matrix& v = dynamic_cast (a); - - return new octave_float_complex_matrix (v.float_complex_matrix_value ()); -} - CONVDECL (float_complex_diag_matrix_to_complex_diag_matrix) { const octave_float_complex_diag_matrix& v = dynamic_cast (a); @@ -109,10 +102,6 @@ INSTALL_BINOP (op_ldiv, octave_float_complex_diag_matrix, octave_float_complex_diag_matrix, ldiv); - INSTALL_CONVOP (octave_float_complex_diag_matrix, octave_complex_diag_matrix, - float_complex_diag_matrix_to_complex_diag_matrix); - INSTALL_CONVOP (octave_float_complex_diag_matrix, octave_float_complex_matrix, - float_complex_diag_matrix_to_float_complex_matrix); INSTALL_ASSIGNCONV (octave_float_complex_diag_matrix, octave_float_complex_matrix, octave_float_complex_matrix); INSTALL_WIDENOP (octave_float_complex_diag_matrix, octave_complex_diag_matrix, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-fcm-fcm.cc --- a/libinterp/operators/op-fcm-fcm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-fcm-fcm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -232,14 +232,6 @@ DEFNDASSIGNOP_FNOP (assign_el_div, float_complex_matrix, float_complex_matrix, float_complex_array, quotient_eq) -CONVDECL (float_complex_matrix_to_complex_matrix) -{ - const octave_float_complex_matrix& v = dynamic_cast (a); - - return - new octave_complex_matrix (ComplexNDArray (v.float_complex_array_value ())); -} - void install_fcm_fcm_ops (void) { @@ -334,7 +326,4 @@ octave_float_complex_matrix, assign_el_mul); INSTALL_ASSIGNOP (op_el_div_eq, octave_float_complex_matrix, octave_float_complex_matrix, assign_el_div); - - INSTALL_CONVOP (octave_float_complex_matrix, octave_complex_matrix, - float_complex_matrix_to_complex_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-fcs-fcs.cc --- a/libinterp/operators/op-fcs-fcs.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-fcs-fcs.cc Mon Aug 15 02:01:29 2016 -0400 @@ -160,15 +160,6 @@ DEFNDCATOP_FN (fcs_cs, float_complex, complex, float_complex_array, float_complex_array, concat) -CONVDECL (float_complex_to_complex) -{ - const octave_float_complex& v = dynamic_cast (a); - - return new octave_complex_matrix - (ComplexMatrix (1, 1, - static_cast(v.float_complex_value ()))); -} - void install_fcs_fcs_ops (void) { @@ -217,7 +208,4 @@ octave_float_complex_matrix); INSTALL_ASSIGNCONV (octave_float_complex, octave_null_sq_str, octave_float_complex_matrix); - - INSTALL_CONVOP (octave_float_complex, octave_complex_matrix, - float_complex_to_complex); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-fdm-fdm.cc --- a/libinterp/operators/op-fdm-fdm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-fdm-fdm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -70,13 +70,6 @@ v2.float_diag_matrix_value ()); } -CONVDECL (float_diag_matrix_to_diag_matrix) -{ - const octave_float_diag_matrix& v = dynamic_cast (a); - - return new octave_diag_matrix (v.diag_matrix_value ()); -} - CONVDECL (float_diag_matrix_to_float_matrix) { const octave_float_diag_matrix& v = dynamic_cast (a); @@ -103,10 +96,6 @@ INSTALL_BINOP (op_ldiv, octave_float_diag_matrix, octave_float_diag_matrix, ldiv); - INSTALL_CONVOP (octave_float_diag_matrix, octave_float_matrix, - float_diag_matrix_to_float_matrix); - INSTALL_CONVOP (octave_float_diag_matrix, octave_diag_matrix, - float_diag_matrix_to_diag_matrix); INSTALL_ASSIGNCONV (octave_float_diag_matrix, octave_float_matrix, octave_float_matrix); INSTALL_WIDENOP (octave_float_diag_matrix, octave_float_matrix, diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-float-conv.cc --- a/libinterp/operators/op-float-conv.cc Sun Aug 14 20:16:09 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -/* - -Copyright (C) 2004-2015 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#if defined (HAVE_CONFIG_H) -# include "config.h" -#endif - -#include "errwarn.h" -#include "ovl.h" -#include "ov.h" -#include "ov-int8.h" -#include "ov-int16.h" -#include "ov-int32.h" -#include "ov-int64.h" -#include "ov-uint8.h" -#include "ov-uint16.h" -#include "ov-uint32.h" -#include "ov-uint64.h" -#include "ov-bool.h" -#include "ov-bool-mat.h" -#include "ov-range.h" -#include "ov-float.h" -#include "ov-flt-re-mat.h" -#include "ov-str-mat.h" -#include "ov-typeinfo.h" -#include "ops.h" - -// conversion ops - -DEFFLTCONVFN (int8_matrix_to_float_matrix, int8_matrix, int8_array) -DEFFLTCONVFN (int16_matrix_to_float_matrix, int16_matrix, int16_array) -DEFFLTCONVFN (int32_matrix_to_float_matrix, int32_matrix, int32_array) -DEFFLTCONVFN (int64_matrix_to_float_matrix, int64_matrix, int64_array) - -DEFFLTCONVFN (uint8_matrix_to_float_matrix, uint8_matrix, uint8_array) -DEFFLTCONVFN (uint16_matrix_to_float_matrix, uint16_matrix, uint16_array) -DEFFLTCONVFN (uint32_matrix_to_float_matrix, uint32_matrix, uint32_array) -DEFFLTCONVFN (uint64_matrix_to_float_matrix, uint64_matrix, uint64_array) - -DEFFLTCONVFN (int8_scalar_to_float_matrix, int8_scalar, int8_array) -DEFFLTCONVFN (int16_scalar_to_float_matrix, int16_scalar, int16_array) -DEFFLTCONVFN (int32_scalar_to_float_matrix, int32_scalar, int32_array) -DEFFLTCONVFN (int64_scalar_to_float_matrix, int64_scalar, int64_array) - -DEFFLTCONVFN (uint8_scalar_to_float_matrix, uint8_scalar, uint8_array) -DEFFLTCONVFN (uint16_scalar_to_float_matrix, uint16_scalar, uint16_array) -DEFFLTCONVFN (uint32_scalar_to_float_matrix, uint32_scalar, uint32_array) -DEFFLTCONVFN (uint64_scalar_to_float_matrix, uint64_scalar, uint64_array) - -DEFFLTCONVFN (bool_matrix_to_float_matrix, bool_matrix, bool_array) -DEFFLTCONVFN (bool_scalar_to_float_matrix, bool, bool_array) - -DEFFLTCONVFN (range_to_float_matrix, range, float_array) - -DEFSTRFLTCONVFN(char_matrix_str_to_float_matrix, char_matrix_str) -DEFSTRFLTCONVFN(char_matrix_sq_str_to_float_matrix, char_matrix_sq_str) - -DEFFLTCONVFN (float_scalar_to_float_matrix, float_scalar, float_array) - -void -install_float_conv_ops (void) -{ - INSTALL_CONVOP (octave_int8_matrix, octave_float_matrix, - int8_matrix_to_float_matrix); - INSTALL_CONVOP (octave_int16_matrix, octave_float_matrix, - int16_matrix_to_float_matrix); - INSTALL_CONVOP (octave_int32_matrix, octave_float_matrix, - int32_matrix_to_float_matrix); - INSTALL_CONVOP (octave_int64_matrix, octave_float_matrix, - int64_matrix_to_float_matrix); - - INSTALL_CONVOP (octave_uint8_matrix, octave_float_matrix, - uint8_matrix_to_float_matrix); - INSTALL_CONVOP (octave_uint16_matrix, octave_float_matrix, - uint16_matrix_to_float_matrix); - INSTALL_CONVOP (octave_uint32_matrix, octave_float_matrix, - uint32_matrix_to_float_matrix); - INSTALL_CONVOP (octave_uint64_matrix, octave_float_matrix, - uint64_matrix_to_float_matrix); - - INSTALL_CONVOP (octave_int8_scalar, octave_float_matrix, - int8_scalar_to_float_matrix); - INSTALL_CONVOP (octave_int16_scalar, octave_float_matrix, - int16_scalar_to_float_matrix); - INSTALL_CONVOP (octave_int32_scalar, octave_float_matrix, - int32_scalar_to_float_matrix); - INSTALL_CONVOP (octave_int64_scalar, octave_float_matrix, - int64_scalar_to_float_matrix); - - INSTALL_CONVOP (octave_uint8_scalar, octave_float_matrix, - uint8_scalar_to_float_matrix); - INSTALL_CONVOP (octave_uint16_scalar, octave_float_matrix, - uint16_scalar_to_float_matrix); - INSTALL_CONVOP (octave_uint32_scalar, octave_float_matrix, - uint32_scalar_to_float_matrix); - INSTALL_CONVOP (octave_uint64_scalar, octave_float_matrix, - uint64_scalar_to_float_matrix); - - INSTALL_CONVOP (octave_bool_matrix, octave_float_matrix, - bool_matrix_to_float_matrix); - INSTALL_CONVOP (octave_bool, octave_float_matrix, - bool_scalar_to_float_matrix); - - INSTALL_CONVOP (octave_range, octave_float_matrix, range_to_float_matrix); - - INSTALL_CONVOP (octave_char_matrix_str, octave_float_matrix, - char_matrix_str_to_float_matrix); - INSTALL_CONVOP (octave_char_matrix_sq_str, octave_float_matrix, - char_matrix_sq_str_to_float_matrix); - - INSTALL_CONVOP (octave_float_scalar, octave_float_matrix, - float_scalar_to_float_matrix); -} diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-fm-fm.cc --- a/libinterp/operators/op-fm-fm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-fm-fm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -186,13 +186,6 @@ DEFNDASSIGNOP_FNOP (assign_el_div, float_matrix, float_matrix, float_array, quotient_eq) -CONVDECL (float_matrix_to_matrix) -{ - const octave_float_matrix& v = dynamic_cast (a); - - return new octave_matrix (v.array_value ()); -} - void install_fm_fm_ops (void) { @@ -269,6 +262,4 @@ assign_el_mul); INSTALL_ASSIGNOP (op_el_div_eq, octave_float_matrix, octave_float_matrix, assign_el_div); - - INSTALL_CONVOP (octave_float_matrix, octave_matrix, float_matrix_to_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-fs-fs.cc --- a/libinterp/operators/op-fs-fs.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-fs-fs.cc Mon Aug 15 02:01:29 2016 -0400 @@ -137,14 +137,6 @@ DEFNDCATOP_FN (s_fs, scalar, float_scalar, float_array, float_array, concat) DEFNDCATOP_FN (fs_s, float_scalar, scalar, float_array, float_array, concat) -CONVDECL (float_to_matrix) -{ - const octave_float_scalar& v = dynamic_cast (a); - - return new octave_matrix (Matrix (1, 1, - static_cast(v.float_value ()))); -} - void install_fs_fs_ops (void) { @@ -190,6 +182,4 @@ octave_float_matrix); INSTALL_ASSIGNCONV (octave_float_scalar, octave_null_sq_str, octave_float_matrix); - - INSTALL_CONVOP (octave_float_scalar, octave_matrix, float_to_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-int-conv.cc --- a/libinterp/operators/op-int-conv.cc Sun Aug 14 20:16:09 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,259 +0,0 @@ -/* - -Copyright (C) 2004-2015 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#if defined (HAVE_CONFIG_H) -# include "config.h" -#endif - -#include "errwarn.h" -#include "ovl.h" -#include "ov.h" -#include "ov-int8.h" -#include "ov-int16.h" -#include "ov-int32.h" -#include "ov-int64.h" -#include "ov-uint8.h" -#include "ov-uint16.h" -#include "ov-uint32.h" -#include "ov-uint64.h" -#include "ov-range.h" -#include "ov-bool.h" -#include "ov-bool-mat.h" -#include "ov-scalar.h" -#include "ov-float.h" -#include "ov-re-mat.h" -#include "ov-flt-re-mat.h" -#include "ov-str-mat.h" -#include "ov-typeinfo.h" -#include "ops.h" - -#define DEFINTCONVFN(name, tfrom, tto) \ - CONVDECL (name) \ - { \ - const octave_ ## tfrom& v = dynamic_cast (a); \ - \ - octave_ ## tto ## _matrix v2 = v.tto ## _array_value (); \ - return new octave_ ## tto ## _matrix (v2); \ - } - -// conversion ops - -DEFINTCONVFN (scalar_to_int8, scalar, int8) -DEFINTCONVFN (scalar_to_int16, scalar, int16) -DEFINTCONVFN (scalar_to_int32, scalar, int32) -DEFINTCONVFN (scalar_to_int64, scalar, int64) - -DEFINTCONVFN (scalar_to_uint8, scalar, uint8) -DEFINTCONVFN (scalar_to_uint16, scalar, uint16) -DEFINTCONVFN (scalar_to_uint32, scalar, uint32) -DEFINTCONVFN (scalar_to_uint64, scalar, uint64) - -DEFINTCONVFN (matrix_to_int8, matrix, int8) -DEFINTCONVFN (matrix_to_int16, matrix, int16) -DEFINTCONVFN (matrix_to_int32, matrix, int32) -DEFINTCONVFN (matrix_to_int64, matrix, int64) - -DEFINTCONVFN (matrix_to_uint8, matrix, uint8) -DEFINTCONVFN (matrix_to_uint16, matrix, uint16) -DEFINTCONVFN (matrix_to_uint32, matrix, uint32) -DEFINTCONVFN (matrix_to_uint64, matrix, uint64) - -DEFINTCONVFN (float_scalar_to_int8, float_scalar, int8) -DEFINTCONVFN (float_scalar_to_int16, float_scalar, int16) -DEFINTCONVFN (float_scalar_to_int32, float_scalar, int32) -DEFINTCONVFN (float_scalar_to_int64, float_scalar, int64) - -DEFINTCONVFN (float_scalar_to_uint8, float_scalar, uint8) -DEFINTCONVFN (float_scalar_to_uint16, float_scalar, uint16) -DEFINTCONVFN (float_scalar_to_uint32, float_scalar, uint32) -DEFINTCONVFN (float_scalar_to_uint64, float_scalar, uint64) - -DEFINTCONVFN (float_matrix_to_int8, float_matrix, int8) -DEFINTCONVFN (float_matrix_to_int16, float_matrix, int16) -DEFINTCONVFN (float_matrix_to_int32, float_matrix, int32) -DEFINTCONVFN (float_matrix_to_int64, float_matrix, int64) - -DEFINTCONVFN (float_matrix_to_uint8, float_matrix, uint8) -DEFINTCONVFN (float_matrix_to_uint16, float_matrix, uint16) -DEFINTCONVFN (float_matrix_to_uint32, float_matrix, uint32) -DEFINTCONVFN (float_matrix_to_uint64, float_matrix, uint64) - -DEFCONVFN (bool_to_int8, bool, int8) -DEFCONVFN (bool_to_int16, bool, int16) -DEFCONVFN (bool_to_int32, bool, int32) -DEFCONVFN (bool_to_int64, bool, int64) - -DEFCONVFN (bool_to_uint8, bool, uint8) -DEFCONVFN (bool_to_uint16, bool, uint16) -DEFCONVFN (bool_to_uint32, bool, uint32) -DEFCONVFN (bool_to_uint64, bool, uint64) - -DEFCONVFN (bool_matrix_to_int8, bool_matrix, int8) -DEFCONVFN (bool_matrix_to_int16, bool_matrix, int16) -DEFCONVFN (bool_matrix_to_int32, bool_matrix, int32) -DEFCONVFN (bool_matrix_to_int64, bool_matrix, int64) - -DEFCONVFN (bool_matrix_to_uint8, bool_matrix, uint8) -DEFCONVFN (bool_matrix_to_uint16, bool_matrix, uint16) -DEFCONVFN (bool_matrix_to_uint32, bool_matrix, uint32) -DEFCONVFN (bool_matrix_to_uint64, bool_matrix, uint64) - -DEFSTRINTCONVFN (char_matrix_sq_str_to_int8, int8) -DEFSTRINTCONVFN (char_matrix_sq_str_to_int16, int16) -DEFSTRINTCONVFN (char_matrix_sq_str_to_int32, int32) -DEFSTRINTCONVFN (char_matrix_sq_str_to_int64, int64) - -DEFSTRINTCONVFN (char_matrix_sq_str_to_uint8, uint8) -DEFSTRINTCONVFN (char_matrix_sq_str_to_uint16, uint16) -DEFSTRINTCONVFN (char_matrix_sq_str_to_uint32, uint32) -DEFSTRINTCONVFN (char_matrix_sq_str_to_uint64, uint64) - -DEFSTRINTCONVFN (char_matrix_dq_str_to_int8, int8) -DEFSTRINTCONVFN (char_matrix_dq_str_to_int16, int16) -DEFSTRINTCONVFN (char_matrix_dq_str_to_int32, int32) -DEFSTRINTCONVFN (char_matrix_dq_str_to_int64, int64) - -DEFSTRINTCONVFN (char_matrix_dq_str_to_uint8, uint8) -DEFSTRINTCONVFN (char_matrix_dq_str_to_uint16, uint16) -DEFSTRINTCONVFN (char_matrix_dq_str_to_uint32, uint32) -DEFSTRINTCONVFN (char_matrix_dq_str_to_uint64, uint64) - -DEFINTCONVFN (range_to_int8, range, int8) -DEFINTCONVFN (range_to_int16, range, int16) -DEFINTCONVFN (range_to_int32, range, int32) -DEFINTCONVFN (range_to_int64, range, int64) - -DEFINTCONVFN (range_to_uint8, range, uint8) -DEFINTCONVFN (range_to_uint16, range, uint16) -DEFINTCONVFN (range_to_uint32, range, uint32) -DEFINTCONVFN (range_to_uint64, range, uint64) - -#define INT_CONV_FUNCTIONS(tfrom) \ - DEFCONVFN2 (tfrom ## _scalar_to_int8, tfrom, scalar, int8) \ - DEFCONVFN2 (tfrom ## _scalar_to_int16, tfrom, scalar, int16) \ - DEFCONVFN2 (tfrom ## _scalar_to_int32, tfrom, scalar, int32) \ - DEFCONVFN2 (tfrom ## _scalar_to_int64, tfrom, scalar, int64) \ - \ - DEFCONVFN2 (tfrom ## _scalar_to_uint8, tfrom, scalar, uint8) \ - DEFCONVFN2 (tfrom ## _scalar_to_uint16, tfrom, scalar, uint16) \ - DEFCONVFN2 (tfrom ## _scalar_to_uint32, tfrom, scalar, uint32) \ - DEFCONVFN2 (tfrom ## _scalar_to_uint64, tfrom, scalar, uint64) \ - \ - DEFCONVFN2 (tfrom ## _matrix_to_int8, tfrom, matrix, int8) \ - DEFCONVFN2 (tfrom ## _matrix_to_int16, tfrom, matrix, int16) \ - DEFCONVFN2 (tfrom ## _matrix_to_int32, tfrom, matrix, int32) \ - DEFCONVFN2 (tfrom ## _matrix_to_int64, tfrom, matrix, int64) \ - \ - DEFCONVFN2 (tfrom ## _matrix_to_uint8, tfrom, matrix, uint8) \ - DEFCONVFN2 (tfrom ## _matrix_to_uint16, tfrom, matrix, uint16) \ - DEFCONVFN2 (tfrom ## _matrix_to_uint32, tfrom, matrix, uint32) \ - DEFCONVFN2 (tfrom ## _matrix_to_uint64, tfrom, matrix, uint64) - -INT_CONV_FUNCTIONS (int8) -INT_CONV_FUNCTIONS (int16) -INT_CONV_FUNCTIONS (int32) -INT_CONV_FUNCTIONS (int64) - -INT_CONV_FUNCTIONS (uint8) -INT_CONV_FUNCTIONS (uint16) -INT_CONV_FUNCTIONS (uint32) -INT_CONV_FUNCTIONS (uint64) - -#define INSTALL_INT_CONV_FUNCTIONS(tfrom) \ - INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int8_matrix, \ - tfrom ## _scalar_to_int8) \ - INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int16_matrix, \ - tfrom ## _scalar_to_int16) \ - INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int32_matrix, \ - tfrom ## _scalar_to_int32) \ - INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int64_matrix, \ - tfrom ## _scalar_to_int64) \ - \ - INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint8_matrix, \ - tfrom ## _scalar_to_uint8) \ - INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint16_matrix, \ - tfrom ## _scalar_to_uint16) \ - INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint32_matrix, \ - tfrom ## _scalar_to_uint32) \ - INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint64_matrix, \ - tfrom ## _scalar_to_uint64) \ - \ - INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int8_matrix, \ - tfrom ## _matrix_to_int8) \ - INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int16_matrix, \ - tfrom ## _matrix_to_int16) \ - INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int32_matrix, \ - tfrom ## _matrix_to_int32) \ - INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int64_matrix, \ - tfrom ## _matrix_to_int64) \ - \ - INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint8_matrix, \ - tfrom ## _matrix_to_uint8) \ - INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint16_matrix, \ - tfrom ## _matrix_to_uint16) \ - INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint32_matrix, \ - tfrom ## _matrix_to_uint32) \ - INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint64_matrix, \ - tfrom ## _matrix_to_uint64) - -#define INSTALL_CONVOPS(tfrom) \ - INSTALL_CONVOP (octave_ ## tfrom, octave_int8_matrix, \ - tfrom ## _to_int8) \ - INSTALL_CONVOP (octave_ ## tfrom, octave_int16_matrix, \ - tfrom ## _to_int16) \ - INSTALL_CONVOP (octave_ ## tfrom, octave_int32_matrix, \ - tfrom ## _to_int32) \ - INSTALL_CONVOP (octave_ ## tfrom, octave_int64_matrix, \ - tfrom ## _to_int64) \ - \ - INSTALL_CONVOP (octave_ ## tfrom, octave_uint8_matrix, \ - tfrom ## _to_uint8) \ - INSTALL_CONVOP (octave_ ## tfrom, octave_uint16_matrix, \ - tfrom ## _to_uint16) \ - INSTALL_CONVOP (octave_ ## tfrom, octave_uint32_matrix, \ - tfrom ## _to_uint32) \ - INSTALL_CONVOP (octave_ ## tfrom, octave_uint64_matrix, \ - tfrom ## _to_uint64) - -void -install_int_conv_ops (void) -{ - INSTALL_CONVOPS (scalar) - INSTALL_CONVOPS (matrix) - INSTALL_CONVOPS (float_scalar) - INSTALL_CONVOPS (float_matrix) - INSTALL_CONVOPS (bool) - INSTALL_CONVOPS (bool_matrix) - INSTALL_CONVOPS (range) - INSTALL_CONVOPS (char_matrix_sq_str) - INSTALL_CONVOPS (char_matrix_dq_str) - - INSTALL_INT_CONV_FUNCTIONS (int8) - INSTALL_INT_CONV_FUNCTIONS (int16) - INSTALL_INT_CONV_FUNCTIONS (int32) - INSTALL_INT_CONV_FUNCTIONS (int64) - - INSTALL_INT_CONV_FUNCTIONS (uint8) - INSTALL_INT_CONV_FUNCTIONS (uint16) - INSTALL_INT_CONV_FUNCTIONS (uint32) - INSTALL_INT_CONV_FUNCTIONS (uint64) -} diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-m-m.cc --- a/libinterp/operators/op-m-m.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-m-m.cc Mon Aug 15 02:01:29 2016 -0400 @@ -158,13 +158,6 @@ DEFNDASSIGNOP_FNOP (assign_el_mul, matrix, matrix, array, product_eq) DEFNDASSIGNOP_FNOP (assign_el_div, matrix, matrix, array, quotient_eq) -CONVDECL (matrix_to_float_matrix) -{ - const octave_matrix& v = dynamic_cast (a); - - return new octave_float_matrix (FloatNDArray (v.array_value ())); -} - void install_m_m_ops (void) { @@ -220,6 +213,4 @@ INSTALL_ASSIGNOP (op_sub_eq, octave_matrix, octave_matrix, assign_sub); INSTALL_ASSIGNOP (op_el_mul_eq, octave_matrix, octave_matrix, assign_el_mul); INSTALL_ASSIGNOP (op_el_div_eq, octave_matrix, octave_matrix, assign_el_div); - - INSTALL_CONVOP (octave_matrix, octave_float_matrix, matrix_to_float_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-pm-pm.cc --- a/libinterp/operators/op-pm-pm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-pm-pm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -84,7 +84,6 @@ INSTALL_BINOP (op_ldiv, octave_perm_matrix, octave_perm_matrix, ldiv); INSTALL_BINOP (op_pow, octave_perm_matrix, octave_scalar, pow); - INSTALL_CONVOP (octave_perm_matrix, octave_matrix, perm_matrix_to_matrix); INSTALL_ASSIGNCONV (octave_perm_matrix, octave_matrix, octave_matrix); INSTALL_WIDENOP (octave_perm_matrix, octave_matrix, perm_matrix_to_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-s-s.cc --- a/libinterp/operators/op-s-s.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-s-s.cc Mon Aug 15 02:01:29 2016 -0400 @@ -135,13 +135,6 @@ DEFNDCATOP_FN (s_s, scalar, scalar, array, array, concat) -CONVDECL (double_to_float_matrix) -{ - const octave_scalar& v = dynamic_cast (a); - - return new octave_float_matrix (FloatMatrix (1, 1, static_cast(v.double_value ()))); -} - void install_s_s_ops (void) { @@ -181,6 +174,4 @@ INSTALL_ASSIGNCONV (octave_scalar, octave_null_matrix, octave_matrix); INSTALL_ASSIGNCONV (octave_scalar, octave_null_str, octave_matrix); INSTALL_ASSIGNCONV (octave_scalar, octave_null_sq_str, octave_matrix); - - INSTALL_CONVOP (octave_scalar, octave_float_matrix, double_to_float_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/op-sbm-sbm.cc --- a/libinterp/operators/op-sbm-sbm.cc Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/op-sbm-sbm.cc Mon Aug 15 02:01:29 2016 -0400 @@ -75,14 +75,6 @@ DEFASSIGNOP_FN (assign, sparse_bool_matrix, sparse_bool_matrix, assign) -CONVDECL (bool_matrix_to_double_matrix) -{ - const octave_sparse_bool_matrix& v = dynamic_cast (a); - - return new octave_sparse_matrix (SparseMatrix - (v.sparse_bool_matrix_value ())); -} - void install_sbm_sbm_ops (void) { @@ -109,7 +101,4 @@ INSTALL_ASSIGNOP (op_asn_eq, octave_sparse_bool_matrix, octave_sparse_bool_matrix, assign); - - INSTALL_CONVOP (octave_sparse_bool_matrix, octave_sparse_matrix, - bool_matrix_to_double_matrix); } diff -r 12f1d273d22a -r 8b18f46f6427 libinterp/operators/ops.h --- a/libinterp/operators/ops.h Sun Aug 14 20:16:09 2016 -0700 +++ b/libinterp/operators/ops.h Mon Aug 15 02:01:29 2016 -0400 @@ -67,10 +67,6 @@ octave_value_typeinfo::register_pref_assign_conv \ (t1::static_type_id (), t2::static_type_id (), tr::static_type_id ()); -#define INSTALL_CONVOP(t1, t2, f) \ - octave_value_typeinfo::register_type_conv_op \ - (t1::static_type_id (), t2::static_type_id (), CONCAT2 (oct_conv_, f)); - #define INSTALL_WIDENOP(t1, t2, f) \ octave_value_typeinfo::register_widening_op \ (t1::static_type_id (), t2::static_type_id (), CONCAT2 (oct_conv_, f)); @@ -166,60 +162,9 @@ static octave_base_value * \ CONCAT2 (oct_conv_, name) (const octave_base_value& a) -#define CONVDECLX(name) \ - static octave_base_value * \ - CONCAT2 (oct_conv_, name) (const octave_base_value&) - #define DEFCONV(name, a_dummy, b_dummy) \ CONVDECL (name) -#define DEFCONVFNX(name, tfrom, ovtto, tto, e) \ - CONVDECL (name) \ - { \ - const CONCAT2 (octave_, tfrom)& v = dynamic_cast (a); \ - \ - return new CONCAT2 (octave_, ovtto) (CONCAT2 (tto, NDArray) (v.CONCAT2 (e, array_value) ())); \ - } - -#define DEFCONVFNX2(name, tfrom, ovtto, e) \ - CONVDECL (name) \ - { \ - const CONCAT2 (octave_, tfrom)& v = dynamic_cast (a); \ - \ - return new CONCAT2 (octave_, ovtto) (v.CONCAT2 (e, array_value) ()); \ - } - -#define DEFDBLCONVFN(name, ovtfrom, e) \ - CONVDECL (name) \ - { \ - const CONCAT2 (octave_, ovtfrom)& v = dynamic_cast (a); \ - \ - return new octave_matrix (NDArray (v.CONCAT2 (e, _value) ())); \ - } - -#define DEFFLTCONVFN(name, ovtfrom, e) \ - CONVDECL (name) \ - { \ - const CONCAT2 (octave_, ovtfrom)& v = dynamic_cast (a); \ - \ - return new octave_float_matrix (FloatNDArray (v.CONCAT2 (e, _value) ())); \ - } - -#define DEFSTRINTCONVFN(name, tto) \ - DEFCONVFNX(name, char_matrix_str, CONCAT2 (tto, _matrix), tto, char_) - -#define DEFSTRDBLCONVFN(name, tfrom) \ - DEFCONVFNX(name, tfrom, matrix, , char_) - -#define DEFSTRFLTCONVFN(name, tfrom) \ - DEFCONVFNX(name, tfrom, float_matrix, Float, char_) - -#define DEFCONVFN(name, tfrom, tto) \ - DEFCONVFNX2 (name, tfrom, CONCAT2 (tto, _matrix), CONCAT2 (tto, _)) - -#define DEFCONVFN2(name, tfrom, sm, tto) \ - DEFCONVFNX2 (name, CONCAT3 (tfrom, _, sm), CONCAT2 (tto, _matrix), CONCAT2 (tto, _)) - #define DEFUNOPX(name, t) \ static octave_value \ CONCAT2 (oct_unop_, name) (const octave_base_value&)