Mercurial > hg > octave-lyh
changeset 14465:16164cb3b713
maint: periodic merge of stable to default
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 15 Mar 2012 13:28:42 -0400 |
parents | bec37a92cb3b (current diff) 21ac4b576003 (diff) |
children | cfb0173fe1ca |
files | scripts/polynomial/pchip.m |
diffstat | 3 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/polynomial/pchip.m +++ b/scripts/polynomial/pchip.m @@ -125,7 +125,6 @@ endfunction - %!demo %! x = 0:8; %! y = [1, 1, 1, 1, 0.5, 0, 0, 0, 0]; @@ -169,3 +168,5 @@ %!assert (size (yi2), [3,2,5,4]) %!assert (squeeze (yi2(1,2,3,:)), [1/sqrt(2); 0; -1/sqrt(2);-1], 1e-14) +%!error (pchip (1,2)); +%!error (pchip (1,2,3));
--- a/src/DLD-FUNCTIONS/__pchip_deriv__.cc +++ b/src/DLD-FUNCTIONS/__pchip_deriv__.cc @@ -69,6 +69,13 @@ FloatMatrix ymat (args(1).float_matrix_value ()); octave_idx_type nx = xvec.length (); + + if (nx < 2) + { + error ("__pchip_deriv__: X must be at least of length 2"); + return retval; + } + octave_idx_type nyr = ymat.rows (); octave_idx_type nyc = ymat.columns (); @@ -109,6 +116,13 @@ Matrix ymat (args(1).matrix_value ()); octave_idx_type nx = xvec.length (); + + if (nx < 2) + { + error ("__pchip_deriv__: X must be at least of length 2"); + return retval; + } + octave_idx_type nyr = ymat.rows (); octave_idx_type nyc = ymat.columns ();
--- a/src/ov-base-scalar.h +++ b/src/ov-base-scalar.h @@ -71,6 +71,9 @@ const std::list<octave_value_list>& idx, const octave_value& rhs); + octave_value_list do_multi_index_op (int, const octave_value_list& idx) + { return do_index_op (idx); } + bool is_constant (void) const { return true; } bool is_defined (void) const { return true; }