# HG changeset patch # User jwe # Date 947654617 0 # Node ID e71b3d1dd3279cea3c37aa98287a1e935c2958cf # Parent ca92c9d3f8826c0a7d6f3892a5c323200f5c9e42 [project @ 2000-01-12 05:23:34 by jwe] diff -r ca92c9d3f882 -r e71b3d1dd327 liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Jan 12 03:07:52 2000 +0000 +++ b/liboctave/ChangeLog Wed Jan 12 05:23:37 2000 +0000 @@ -1,3 +1,7 @@ +2000-01-11 John W. Eaton + + * MArray.h (MArray &)): New constructor. + 2000-01-10 John W. Eaton * pathsearch.cc (dir_path::all_directories): Avoid dereferencing diff -r ca92c9d3f882 -r e71b3d1dd327 liboctave/MArray.h --- a/liboctave/MArray.h Wed Jan 12 03:07:52 2000 +0000 +++ b/liboctave/MArray.h Wed Jan 12 05:23:37 2000 +0000 @@ -109,7 +109,7 @@ MArray (void) : Array () { } MArray (int n) : Array (n) { } MArray (int n, const T& val) : Array (n, val) { } -// MArray (const Array& a) : Array (a) { } + MArray (const Array& a) : Array (a) { } MArray (const MArray& a) : Array (a) { } ~MArray (void) { } diff -r ca92c9d3f882 -r e71b3d1dd327 src/ChangeLog --- a/src/ChangeLog Wed Jan 12 03:07:52 2000 +0000 +++ b/src/ChangeLog Wed Jan 12 05:23:37 2000 +0000 @@ -1,10 +1,19 @@ 2000-01-11 John W. Eaton + * ov.h, ov.cc (octave_value::column_vector_value, + octave_value::row_vector_value, + octave_value::complex_column_vector_value, + octave_value::complex_row_vector_value): New functions. + (octave_value::vector_value): Now returns Array. + (octave_value::complex_vector_value): Now returns Array. + Sprinkle conversions where necessary. + * ov.cc (Vprefer_column_vectors): Now static. * ov.h (octave_value (const ComplexRowVector&), octave_value (const ComplexColumnVector&), octave_value (const RowVector&), octave_value (const ColumnVector&)): Delete second arg. Change all callers. + * oct-obj.h (octave_value_list (const RowVector&), octave_value_list (const ColumnVector&), octave_value_list (const ComplexRowVector&), diff -r ca92c9d3f882 -r e71b3d1dd327 src/DLD-FUNCTIONS/dassl.cc --- a/src/DLD-FUNCTIONS/dassl.cc Wed Jan 12 03:07:52 2000 +0000 +++ b/src/DLD-FUNCTIONS/dassl.cc Wed Jan 12 05:23:37 2000 +0000 @@ -96,7 +96,7 @@ if (tmp.length () > 0 && tmp(0).is_defined ()) { - retval = tmp(0).vector_value (); + retval = ColumnVector (tmp(0).vector_value ()); if (error_state || retval.length () == 0) gripe_user_supplied_eval ("dassl"); @@ -192,17 +192,17 @@ if (! dassl_fcn) DASSL_ABORT (); - ColumnVector state = args(1).vector_value (); + ColumnVector state = ColumnVector (args(1).vector_value ()); if (error_state) DASSL_ABORT1 ("expecting state vector as second argument"); - ColumnVector deriv = args(2).vector_value (); + ColumnVector deriv (args(2).vector_value ()); if (error_state) DASSL_ABORT1 ("expecting derivative vector as third argument"); - ColumnVector out_times = args(3).vector_value (); + ColumnVector out_times (args(3).vector_value ()); if (error_state) DASSL_ABORT1 ("expecting output time vector as fourth argument"); @@ -211,7 +211,7 @@ int crit_times_set = 0; if (nargin > 4) { - crit_times = args(4).vector_value (); + crit_times = ColumnVector (args(4).vector_value ()); if (error_state) DASSL_ABORT1 ("expecting critical time vector as fifth argument"); diff -r ca92c9d3f882 -r e71b3d1dd327 src/DLD-FUNCTIONS/filter.cc --- a/src/DLD-FUNCTIONS/filter.cc Wed Jan 12 03:07:52 2000 +0000 +++ b/src/DLD-FUNCTIONS/filter.cc Wed Jan 12 05:23:37 2000 +0000 @@ -266,9 +266,9 @@ || args(2).is_complex_type () || (nargin == 4 && args(3).is_complex_type ())) { - ComplexColumnVector b = args(0).complex_vector_value (); - ComplexColumnVector a = args(1).complex_vector_value (); - ComplexColumnVector x = args(2).complex_vector_value (); + ComplexColumnVector b (args(0).complex_vector_value ()); + ComplexColumnVector a (args(1).complex_vector_value ()); + ComplexColumnVector x (args(2).complex_vector_value ()); if (! error_state) { @@ -284,7 +284,7 @@ si.resize (si_len, 0.0); } else - si = args(3).complex_vector_value (); + si = ComplexColumnVector (args(3).complex_vector_value ()); if (! error_state) { @@ -311,9 +311,9 @@ } else { - ColumnVector b = args(0).vector_value (); - ColumnVector a = args(1).vector_value (); - ColumnVector x = args(2).vector_value (); + ColumnVector b (args(0).vector_value ()); + ColumnVector a (args(1).vector_value ()); + ColumnVector x (args(2).vector_value ()); if (! error_state) { @@ -329,7 +329,7 @@ si.resize (si_len, 0.0); } else - si = args(3).vector_value (); + si = ColumnVector (args(3).vector_value ()); if (! error_state) { diff -r ca92c9d3f882 -r e71b3d1dd327 src/DLD-FUNCTIONS/fsolve.cc --- a/src/DLD-FUNCTIONS/fsolve.cc Wed Jan 12 03:07:52 2000 +0000 +++ b/src/DLD-FUNCTIONS/fsolve.cc Wed Jan 12 05:23:37 2000 +0000 @@ -112,7 +112,7 @@ octave_value_list tmp = fsolve_fcn->do_index_op (1, args); if (tmp.length () > 0 && tmp(0).is_defined ()) { - retval = tmp(0).vector_value (); + retval = ColumnVector (tmp(0).vector_value ()); if (error_state || retval.length () <= 0) gripe_user_supplied_eval ("fsolve"); @@ -176,7 +176,7 @@ if (! fsolve_fcn) FSOLVE_ABORT (); - ColumnVector x = args(1).vector_value (); + ColumnVector x (args(1).vector_value ()); if (error_state) FSOLVE_ABORT1 ("expecting vector as second argument"); diff -r ca92c9d3f882 -r e71b3d1dd327 src/DLD-FUNCTIONS/lsode.cc --- a/src/DLD-FUNCTIONS/lsode.cc Wed Jan 12 03:07:52 2000 +0000 +++ b/src/DLD-FUNCTIONS/lsode.cc Wed Jan 12 05:23:37 2000 +0000 @@ -80,7 +80,7 @@ if (tmp.length () > 0 && tmp(0).is_defined ()) { - retval = tmp(0).vector_value (); + retval = ColumnVector (tmp(0).vector_value ()); if (error_state || retval.length () == 0) gripe_user_supplied_eval ("lsode"); @@ -240,12 +240,12 @@ if (error_state || ! lsode_fcn) LSODE_ABORT (); - ColumnVector state = args(1).vector_value (); + ColumnVector state (args(1).vector_value ()); if (error_state) LSODE_ABORT1 ("expecting state vector as second argument"); - ColumnVector out_times = args(2).vector_value (); + ColumnVector out_times (args(2).vector_value ()); if (error_state) LSODE_ABORT1 ("expecting output time vector as third argument"); @@ -255,7 +255,7 @@ int crit_times_set = 0; if (nargin > 3) { - crit_times = args(3).vector_value (); + crit_times = ColumnVector (args(3).vector_value ()); if (error_state) LSODE_ABORT1 ("expecting critical time vector as fourth argument"); diff -r ca92c9d3f882 -r e71b3d1dd327 src/DLD-FUNCTIONS/quad.cc --- a/src/DLD-FUNCTIONS/quad.cc Wed Jan 12 03:07:52 2000 +0000 +++ b/src/DLD-FUNCTIONS/quad.cc Wed Jan 12 05:23:37 2000 +0000 @@ -218,13 +218,13 @@ have_sing = 1; - sing = args(4).vector_value (); + sing = ColumnVector (args(4).vector_value ()); if (error_state) QUAD_ABORT1 ("expecting vector of singularities as fourth argument"); case 4: - tol = args(3).vector_value (); + tol = ColumnVector (args(3).vector_value ()); if (error_state) QUAD_ABORT1 ("expecting vector of tolerances as fifth argument"); diff -r ca92c9d3f882 -r e71b3d1dd327 src/ov.cc --- a/src/ov.cc Wed Jan 12 03:07:52 2000 +0000 +++ b/src/ov.cc Wed Jan 12 05:23:37 2000 +0000 @@ -754,10 +754,128 @@ } ColumnVector +octave_value::column_vector_value (bool force_string_conv, + bool force_vector_conversion) const +{ + ColumnVector retval; + + Matrix m = matrix_value (force_string_conv); + + if (error_state) + return retval; + + int nr = m.rows (); + int nc = m.columns (); + + if (nc == 1) + { + retval.resize (nr); + for (int i = 0; i < nr; i++) + retval (i) = m (i, 0); + } + else + { + string tn = type_name (); + gripe_invalid_conversion (tn.c_str (), "real column vector"); + } + + return retval; +} + +ComplexColumnVector +octave_value::complex_column_vector_value (bool force_string_conv, + bool force_vector_conversion) const +{ + ComplexColumnVector retval; + + ComplexMatrix m = complex_matrix_value (force_string_conv); + + if (error_state) + return retval; + + int nr = m.rows (); + int nc = m.columns (); + + if (nc == 1) + { + retval.resize (nc); + for (int i = 0; i < nc; i++) + retval (i) = m (i, 0); + } + else + { + string tn = type_name (); + gripe_invalid_conversion (tn.c_str (), "complex column vector"); + } + + return retval; +} + +RowVector +octave_value::row_vector_value (bool force_string_conv, + bool force_vector_conversion) const +{ + RowVector retval; + + Matrix m = matrix_value (force_string_conv); + + if (error_state) + return retval; + + int nr = m.rows (); + int nc = m.columns (); + + if (nr == 1) + { + retval.resize (nc); + for (int i = 0; i < nc; i++) + retval (i) = m (0, i); + } + else + { + string tn = type_name (); + gripe_invalid_conversion (tn.c_str (), "real row vector"); + } + + return retval; +} + +ComplexRowVector +octave_value::complex_row_vector_value (bool force_string_conv, + bool force_vector_conversion) const +{ + ComplexRowVector retval; + + ComplexMatrix m = complex_matrix_value (force_string_conv); + + if (error_state) + return retval; + + int nr = m.rows (); + int nc = m.columns (); + + if (nr == 1) + { + retval.resize (nc); + for (int i = 0; i < nc; i++) + retval (i) = m (0, i); + } + else + { + string tn = type_name (); + gripe_invalid_conversion (tn.c_str (), "complex row vector"); + } + + return retval; +} + +// Sloppy... + +Array octave_value::vector_value (bool force_string_conv, bool force_vector_conversion) const { - ColumnVector retval; + Array retval; Matrix m = matrix_value (force_string_conv); @@ -797,11 +915,11 @@ return retval; } -ComplexColumnVector +Array octave_value::complex_vector_value (bool force_string_conv, bool force_vector_conversion) const { - ComplexColumnVector retval; + Array retval; ComplexMatrix m = complex_matrix_value (force_string_conv); diff -r ca92c9d3f882 -r e71b3d1dd327 src/ov.h --- a/src/ov.h Wed Jan 12 03:07:52 2000 +0000 +++ b/src/ov.h Wed Jan 12 05:23:37 2000 +0000 @@ -446,13 +446,26 @@ virtual boolMatrix bool_matrix_value (void) const { return rep->bool_matrix_value (); } - ColumnVector vector_value (bool frc_str_conv = false, + ColumnVector column_vector_value (bool frc_str_conv = false, bool frc_vec_conv = false) const; ComplexColumnVector - complex_vector_value (bool frc_str_conv = false, + complex_column_vector_value (bool frc_str_conv = false, bool frc_vec_conv = false) const; + RowVector row_vector_value (bool frc_str_conv = false, + bool frc_vec_conv = false) const; + + ComplexRowVector + complex_row_vector_value (bool frc_str_conv = false, + bool frc_vec_conv = false) const; + + Array vector_value (bool frc_str_conv = false, + bool frc_vec_conv = false) const; + + Array complex_vector_value (bool frc_str_conv = false, + bool frc_vec_conv = false) const; + // Conversions. These should probably be private. If a user of this // class wants a certain kind of constant, he should simply ask for // it, and we should convert it if possible. diff -r ca92c9d3f882 -r e71b3d1dd327 src/utils.cc --- a/src/utils.cc Wed Jan 12 03:07:52 2000 +0000 +++ b/src/utils.cc Wed Jan 12 05:23:37 2000 +0000 @@ -640,7 +640,7 @@ if ((nr == 1 && nc == 2) || (nr == 2 && nc == 1)) { - ColumnVector v = a.vector_value (); + Array v = a.vector_value (); if (error_state) return;