# HG changeset patch # User John W. Eaton # Date 1331832522 14400 # Node ID 16164cb3b7138549736b6f68afd80d7d0310f1af # Parent bec37a92cb3bd070d7c0dceb9d9f39235287b114# Parent 21ac4b576003cfee0d571d257a4c7f64bec408b0 maint: periodic merge of stable to default diff --git a/scripts/polynomial/pchip.m b/scripts/polynomial/pchip.m --- 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)); diff --git a/src/DLD-FUNCTIONS/__pchip_deriv__.cc b/src/DLD-FUNCTIONS/__pchip_deriv__.cc --- 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 (); diff --git a/src/ov-base-scalar.h b/src/ov-base-scalar.h --- a/src/ov-base-scalar.h +++ b/src/ov-base-scalar.h @@ -71,6 +71,9 @@ const std::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; }