changeset 22282:cd2e24983670

new type conversion functions * op-float-conv.cc: Convert range to float array. Convert float scalar to float array. (install_float_conv_ops): Install float scalar to float matrix conversion function for correct types. * op-fs-fs.cc (float_to_matrix): Rename conversion function from float_to_scalar. (install_fs_fs_ops): Update for new name. * op-s-s.cc (double_to_float_matrix): New conversion function. (install_s_s_ops): Install new conversion function.
author John W. Eaton <jwe@octave.org>
date Sat, 13 Aug 2016 17:44:19 -0400
parents 0f9ab4f1f4b3
children 564203123065
files libinterp/operators/op-float-conv.cc libinterp/operators/op-fs-fs.cc libinterp/operators/op-s-s.cc
diffstat 3 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/operators/op-float-conv.cc	Sat Aug 13 17:39:29 2016 -0400
+++ b/libinterp/operators/op-float-conv.cc	Sat Aug 13 17:44:19 2016 -0400
@@ -69,12 +69,12 @@
 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, 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, scalar, array)
+DEFFLTCONVFN (float_scalar_to_float_matrix, float_scalar, float_array)
 
 void
 install_float_conv_ops (void)
@@ -127,6 +127,6 @@
   INSTALL_CONVOP (octave_char_matrix_sq_str, octave_float_matrix,
                   char_matrix_sq_str_to_float_matrix);
 
-  INSTALL_CONVOP (octave_scalar, octave_float_matrix,
+  INSTALL_CONVOP (octave_float_scalar, octave_float_matrix,
                   float_scalar_to_float_matrix);
 }
--- a/libinterp/operators/op-fs-fs.cc	Sat Aug 13 17:39:29 2016 -0400
+++ b/libinterp/operators/op-fs-fs.cc	Sat Aug 13 17:44:19 2016 -0400
@@ -137,7 +137,7 @@
 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_scalar)
+CONVDECL (float_to_matrix)
 {
   const octave_float_scalar& v = dynamic_cast<const octave_float_scalar&> (a);
 
@@ -191,5 +191,5 @@
   INSTALL_ASSIGNCONV (octave_float_scalar, octave_null_sq_str,
                       octave_float_matrix);
 
-  INSTALL_CONVOP (octave_float_scalar, octave_matrix, float_to_scalar);
+  INSTALL_CONVOP (octave_float_scalar, octave_matrix, float_to_matrix);
 }
--- a/libinterp/operators/op-s-s.cc	Sat Aug 13 17:39:29 2016 -0400
+++ b/libinterp/operators/op-s-s.cc	Sat Aug 13 17:44:19 2016 -0400
@@ -135,6 +135,13 @@
 
 DEFNDCATOP_FN (s_s, scalar, scalar, array, array, concat)
 
+CONVDECL (double_to_float_matrix)
+{
+  const octave_scalar& v = dynamic_cast<const octave_scalar&> (a);
+
+  return new octave_float_matrix (FloatMatrix (1, 1, static_cast<float>(v.double_value ())));
+}
+
 void
 install_s_s_ops (void)
 {
@@ -174,4 +181,6 @@
   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);
 }