Mercurial > hg > octave-nkf
changeset 1615:da72f1fae389
[project @ 1995-11-03 15:22:18 by jwe]
author | jwe |
---|---|
date | Fri, 03 Nov 1995 15:22:18 +0000 |
parents | 1c39163722ce |
children | ac7e10016ca0 |
files | src/pt-const.cc |
diffstat | 1 files changed, 58 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -503,8 +503,16 @@ TC_REP::tree_constant_rep (const Complex& c) { - complex_scalar = new Complex (c); - type_tag = complex_scalar_constant; + if (::imag (c) == 0.0) + { + scalar = ::real (c); + type_tag = scalar_constant; + } + else + { + complex_scalar = new Complex (c); + type_tag = complex_scalar_constant; + } orig_text = 0; } @@ -512,8 +520,18 @@ { if (m.rows () == 1 && m.columns () == 1) { - complex_scalar = new Complex (m.elem (0, 0)); - type_tag = complex_scalar_constant; + Complex c = m.elem (0, 0); + + if (::imag (c) == 0.0) + { + scalar = ::real (c); + type_tag = scalar_constant; + } + else + { + complex_scalar = new Complex (c); + type_tag = complex_scalar_constant; + } } else { @@ -527,8 +545,18 @@ { if (d.rows () == 1 && d.columns () == 1) { - complex_scalar = new Complex (d.elem (0, 0)); - type_tag = complex_scalar_constant; + Complex c = d.elem (0, 0); + + if (::imag (c) == 0.0) + { + scalar = ::real (c); + type_tag = scalar_constant; + } + else + { + complex_scalar = new Complex (c); + type_tag = complex_scalar_constant; + } } else { @@ -544,8 +572,18 @@ int len = v.capacity (); if (len == 1) { - complex_scalar = new Complex (v.elem (0)); - type_tag = complex_scalar_constant; + Complex c = v.elem (0); + + if (::imag (c) == 0.0) + { + scalar = ::real (c); + type_tag = scalar_constant; + } + else + { + complex_scalar = new Complex (c); + type_tag = complex_scalar_constant; + } } else { @@ -579,8 +617,18 @@ int len = v.capacity (); if (len == 1) { - complex_scalar = new Complex (v.elem (0)); - type_tag = complex_scalar_constant; + Complex c = v.elem (0); + + if (::imag (c) == 0.0) + { + scalar = ::real (c); + type_tag = scalar_constant; + } + else + { + complex_scalar = new Complex (c); + type_tag = complex_scalar_constant; + } } else { @@ -2837,11 +2885,6 @@ break; } } - -// This is a fairly expensive operation. - - if (originally_scalar_type) - maybe_mutate (); } return retval;