Mercurial > hg > octave-nkf
changeset 3419:e71b3d1dd327
[project @ 2000-01-12 05:23:34 by jwe]
author | jwe |
---|---|
date | Wed, 12 Jan 2000 05:23:37 +0000 |
parents | ca92c9d3f882 |
children | 39496bf0ffdf |
files | liboctave/ChangeLog liboctave/MArray.h src/ChangeLog src/DLD-FUNCTIONS/dassl.cc src/DLD-FUNCTIONS/filter.cc src/DLD-FUNCTIONS/fsolve.cc src/DLD-FUNCTIONS/lsode.cc src/DLD-FUNCTIONS/quad.cc src/ov.cc src/ov.h src/utils.cc |
diffstat | 11 files changed, 172 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +2000-01-11 John W. Eaton <jwe@bevo.che.wisc.edu> + + * MArray.h (MArray <const Array<T>&)): New constructor. + 2000-01-10 John W. Eaton <jwe@bevo.che.wisc.edu> * pathsearch.cc (dir_path::all_directories): Avoid dereferencing
--- a/liboctave/MArray.h +++ b/liboctave/MArray.h @@ -109,7 +109,7 @@ MArray (void) : Array<T> () { } MArray (int n) : Array<T> (n) { } MArray (int n, const T& val) : Array<T> (n, val) { } -// MArray (const Array<T>& a) : Array<T> (a) { } + MArray (const Array<T>& a) : Array<T> (a) { } MArray (const MArray<T>& a) : Array<T> (a) { } ~MArray (void) { }
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,10 +1,19 @@ 2000-01-11 John W. Eaton <jwe@bevo.che.wisc.edu> + * 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<double>. + (octave_value::complex_vector_value): Now returns Array<Complex>. + 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&),
--- a/src/DLD-FUNCTIONS/dassl.cc +++ b/src/DLD-FUNCTIONS/dassl.cc @@ -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");
--- a/src/DLD-FUNCTIONS/filter.cc +++ b/src/DLD-FUNCTIONS/filter.cc @@ -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) {
--- a/src/DLD-FUNCTIONS/fsolve.cc +++ b/src/DLD-FUNCTIONS/fsolve.cc @@ -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");
--- a/src/DLD-FUNCTIONS/lsode.cc +++ b/src/DLD-FUNCTIONS/lsode.cc @@ -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");
--- a/src/DLD-FUNCTIONS/quad.cc +++ b/src/DLD-FUNCTIONS/quad.cc @@ -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");
--- a/src/ov.cc +++ b/src/ov.cc @@ -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<double> octave_value::vector_value (bool force_string_conv, bool force_vector_conversion) const { - ColumnVector retval; + Array<double> retval; Matrix m = matrix_value (force_string_conv); @@ -797,11 +915,11 @@ return retval; } -ComplexColumnVector +Array<Complex> octave_value::complex_vector_value (bool force_string_conv, bool force_vector_conversion) const { - ComplexColumnVector retval; + Array<Complex> retval; ComplexMatrix m = complex_matrix_value (force_string_conv);
--- a/src/ov.h +++ b/src/ov.h @@ -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<double> vector_value (bool frc_str_conv = false, + bool frc_vec_conv = false) const; + + Array<Complex> 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.