# HG changeset patch
# User Julien Bect <jbect@users.sourceforge.net>
# Date 1474014298 -7200
#      Fri Sep 16 10:24:58 2016 +0200
# Node ID 1b1194e4700f3049f85371cc507972ec2bcbb3ac
# Parent  dbe0ec8d53b55e48ee1d8a5d67d3cb59176ba4c3
Remove unnecessary initializations in complex_value methods

 * ov-base-diag.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-ch-mat.cc,
   ov-cx-mat.cc, ov-cx-sparse.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc,
   ov-perm.cc, ov-range.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-str-mat.cc:
   Remove unnecessary initializations and declarations in complex_value methods.
 * ov-str-mat.cc: Simplify macro CHAR_MATRIX_CONV.

diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-base-diag.cc
--- a/libinterp/octave-value/ov-base-diag.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-base-diag.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -338,19 +338,13 @@
 Complex
 octave_base_diag<DMT, MT>::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion (type_name (), "complex scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
                             type_name (), "complex scalar");
 
-  retval = matrix (0, 0);
-
-  return retval;
+  return matrix(0, 0);
 }
 
 template <typename DMT, typename MT>
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-bool-mat.cc
--- a/libinterp/octave-value/ov-bool-mat.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-bool-mat.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -128,19 +128,13 @@
 Complex
 octave_bool_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion ("bool matrix", "complex scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
                             "bool matrix", "complex scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return Complex (matrix(0, 0), 0);
 }
 
 FloatComplex
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-bool-sparse.cc
--- a/libinterp/octave-value/ov-bool-sparse.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-bool-sparse.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -113,10 +113,6 @@
 Complex
 octave_sparse_bool_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion ("bool sparse matrix", "complex scalar");
 
@@ -124,9 +120,7 @@
     warn_implicit_conversion ("Octave:array-to-scalar",
                               "bool sparse matrix", "complex scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return Complex (matrix(0, 0), 0);
 }
 
 octave_value
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-ch-mat.cc
--- a/libinterp/octave-value/ov-ch-mat.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-ch-mat.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -121,19 +121,13 @@
 Complex
 octave_char_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 && columns () == 0)
     err_invalid_conversion ("character matrix", "complex scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
                             "character matrix", "complex scalar");
 
-  retval = static_cast<unsigned char> (matrix(0, 0));
-
-  return retval;
+  return Complex (static_cast<unsigned char> (matrix(0, 0)), 0);
 }
 
 FloatComplex
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-cx-mat.cc
--- a/libinterp/octave-value/ov-cx-mat.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-cx-mat.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -179,19 +179,13 @@
 Complex
 octave_complex_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion ("complex matrix", "complex scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
                             "complex matrix", "complex scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return matrix(0, 0);
 }
 
 FloatComplex
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-cx-sparse.cc
--- a/libinterp/octave-value/ov-cx-sparse.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-cx-sparse.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -138,10 +138,6 @@
 Complex
 octave_sparse_complex_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   // FIXME: maybe this should be a function, valid_as_scalar()
   if (is_empty ())
     err_invalid_conversion ("complex sparse matrix", "real scalar");
@@ -150,9 +146,7 @@
     warn_implicit_conversion ("Octave:array-to-scalar",
                               "complex sparse matrix", "real scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return matrix(0, 0);
 }
 
 ComplexMatrix
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-flt-cx-mat.cc
--- a/libinterp/octave-value/ov-flt-cx-mat.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-flt-cx-mat.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -153,19 +153,13 @@
 Complex
 octave_float_complex_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion ("complex matrix", "complex scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
                             "complex matrix", "complex scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return matrix(0, 0);
 }
 
 FloatComplex
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-flt-re-mat.cc
--- a/libinterp/octave-value/ov-flt-re-mat.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -137,19 +137,13 @@
 Complex
 octave_float_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion ("real matrix", "complex scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
                             "real matrix", "complex scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return Complex (matrix(0, 0), 0);
 }
 
 FloatComplex
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-perm.cc
--- a/libinterp/octave-value/ov-perm.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-perm.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -172,19 +172,13 @@
 Complex
 octave_perm_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion (type_name (), "complex scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
                             type_name (), "complex scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return Complex (matrix(0, 0), 0);
 }
 
 FloatComplex
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-range.cc
--- a/libinterp/octave-value/ov-range.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-range.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -307,10 +307,6 @@
 Complex
 octave_range::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   octave_idx_type nel = range.numel ();
 
   if (nel == 0)
@@ -319,9 +315,7 @@
   warn_implicit_conversion ("Octave:array-to-scalar",
                             "range", "complex scalar");
 
-  retval = range.base ();
-
-  return retval;
+  return Complex (range.base (), 0);
 }
 
 FloatComplex
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-re-mat.cc
--- a/libinterp/octave-value/ov-re-mat.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-re-mat.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -152,19 +152,13 @@
 Complex
 octave_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion ("real matrix", "complex scalar");
 
   warn_implicit_conversion ("Octave:array-to-scalar",
                             "real matrix", "complex scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return Complex (matrix(0, 0), 0);
 }
 
 FloatComplex
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-re-sparse.cc
--- a/libinterp/octave-value/ov-re-sparse.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-re-sparse.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -108,10 +108,6 @@
 Complex
 octave_sparse_matrix::complex_value (bool) const
 {
-  double tmp = lo_ieee_nan_value ();
-
-  Complex retval (tmp, tmp);
-
   // FIXME: maybe this should be a function, valid_as_scalar()
   if (rows () == 0 || columns () == 0)
     err_invalid_conversion ("real sparse matrix", "complex scalar");
@@ -120,9 +116,7 @@
     warn_implicit_conversion ("Octave:array-to-scalar",
                               "real sparse matrix", "complex scalar");
 
-  retval = matrix(0, 0);
-
-  return retval;
+  return Complex (matrix(0, 0), 0);
 }
 
 Matrix
diff -r dbe0ec8d53b5 -r 1b1194e4700f libinterp/octave-value/ov-str-mat.cc
--- a/libinterp/octave-value/ov-str-mat.cc	Thu Sep 15 11:34:20 2016 -0700
+++ b/libinterp/octave-value/ov-str-mat.cc	Fri Sep 16 10:24:58 2016 +0200
@@ -161,53 +161,49 @@
   return octave_value (retval, is_sq_string () ? '\'' : '"');
 }
 
-#define CHAR_MATRIX_CONV(T, INIT, TNAME, FCN)                           \
-  T retval INIT;                                                        \
+#define CHAR_MATRIX_CONV(TNAME, FCN)                                    \
                                                                         \
   if (! force_string_conv)                                              \
     err_invalid_conversion ("string", TNAME);                           \
                                                                         \
   warn_implicit_conversion ("Octave:str-to-num", "string", TNAME);      \
                                                                         \
-  retval = octave_char_matrix::FCN ();                                  \
-                                                                        \
-  return retval
+  return octave_char_matrix::FCN ()
 
 double
 octave_char_matrix_str::double_value (bool force_string_conv) const
 {
-  CHAR_MATRIX_CONV (double, = 0, "real scalar", double_value);
+  CHAR_MATRIX_CONV ("real scalar", double_value);
 }
 
 Complex
 octave_char_matrix_str::complex_value (bool force_string_conv) const
 {
-  CHAR_MATRIX_CONV (Complex, = 0, "complex scalar", complex_value);
+  CHAR_MATRIX_CONV ("complex scalar", complex_value);
 }
 
 Matrix
 octave_char_matrix_str::matrix_value (bool force_string_conv) const
 {
-  CHAR_MATRIX_CONV (Matrix, , "real matrix", matrix_value);
+  CHAR_MATRIX_CONV ("real matrix", matrix_value);
 }
 
 ComplexMatrix
 octave_char_matrix_str::complex_matrix_value (bool force_string_conv) const
 {
-  CHAR_MATRIX_CONV (ComplexMatrix, , "complex matrix", complex_matrix_value);
+  CHAR_MATRIX_CONV ("complex matrix", complex_matrix_value);
 }
 
 NDArray
 octave_char_matrix_str::array_value (bool force_string_conv) const
 {
-  CHAR_MATRIX_CONV (NDArray, , "real N-D array", array_value);
+  CHAR_MATRIX_CONV ("real N-D array", array_value);
 }
 
 ComplexNDArray
 octave_char_matrix_str::complex_array_value (bool force_string_conv) const
 {
-  CHAR_MATRIX_CONV (ComplexNDArray, , "complex N-D array",
-                    complex_array_value);
+  CHAR_MATRIX_CONV ("complex N-D array", complex_array_value);
 }
 
 string_vector
