# HG changeset patch # User jwe # Date 940475393 0 # Node ID b6c74a0772b5be6e0077684644cd485568c9ee38 # Parent b3bef983b12dfe26a607446806193721734c9a67 [project @ 1999-10-21 03:09:52 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 1999-10-20 John W. Eaton + * data.cc (make_diag (const octave_value&, const octave_value&)): + Delete special cases for scalars and simply attempt conversion of + first arg to a matrix value. If that fails, we will still see an + error message. + * Makefile.in (DISTFILES): Add mkgendoc to the list. 1999-10-19 John W. Eaton diff --git a/src/data.cc b/src/data.cc --- a/src/data.cc +++ b/src/data.cc @@ -453,33 +453,12 @@ return retval; } - int n = ABS (k) + 1; - if (a.is_real_type ()) { - if (a.is_scalar_type ()) - { - double d = a.double_value (); + Matrix m = a.matrix_value (); - if (k == 0) - retval = d; - else if (k > 0) - { - Matrix m (n, n, 0.0); - m (0, k) = d; - retval = m; - } - else if (k < 0) - { - Matrix m (n, n, 0.0); - m (-k, 0) = d; - retval = m; - } - } - else if (a.is_matrix_type ()) + if (! error_state) { - Matrix m = a.matrix_value (); - int nr = m.rows (); int nc = m.columns (); @@ -493,34 +472,13 @@ retval = d; } } - else - gripe_wrong_type_arg ("diag", a); } else if (a.is_complex_type ()) { - if (a.is_scalar_type ()) - { - Complex c = a.complex_value (); + ComplexMatrix cm = a.complex_matrix_value (); - if (k == 0) - retval = c; - else if (k > 0) - { - ComplexMatrix m (n, n, 0.0); - m (0, k) = c; - retval = m; - } - else if (k < 0) - { - ComplexMatrix m (n, n, 0.0); - m (-k, 0) = c; - retval = m; - } - } - else if (a.is_matrix_type ()) + if (! error_state) { - ComplexMatrix cm = a.complex_matrix_value (); - int nr = cm.rows (); int nc = cm.columns (); @@ -534,8 +492,6 @@ retval = d; } } - else - gripe_wrong_type_arg ("diag", a); } else gripe_wrong_type_arg ("diag", a);