annotate libinterp/corefcn/__pchip_deriv__.cc @ 20940:48b2ad5ee801

maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity. * libinterp/corefcn/oct-obj.h: Replaced. Contains a #warning issued if used in compilation and includes "ovl.h" instead. Original file renamed to libinterp/octave-value/ovl.h * libinterp/corefcn/oct-obj.cc: Renamed to libinterp/octave-value/ovl.cc. * oct-obj.cc (ovl ()): Added new function to return empty octave_value_list. * libinterp/corefcn/module.mk: Remove oct-obj.cc from build system. * libinterp/octave-value/module.mk: Add ovl.h and ovl.cc to build system. * mk-opts.pl, annotation-dialog.h, Cell.cc, __contourc__.cc, __dsearchn__.cc, __lin_interpn__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, defun.cc, det.cc, dirfns.cc, dlmread.cc, eig.cc, error.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, graphics.cc, gripes.cc, help.cc, hess.cc, hex2num.cc, hook-fcn.h, input.cc, input.h, inv.cc, kron.cc, load-save.cc, lookup.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, lsode.cc, lu.cc, luinc.cc, max.cc, mex.cc, oct-hist.cc, oct-lvalue.cc, oct-lvalue.h, oct-map.h, oct-stream.cc, oct.h, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sparse-xpow.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.h, syscalls.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, xpow.cc, __delaunayn__.cc, __glpk__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, chol.cc, convhulln.cc, dmperm.cc, qr.cc, symbfact.cc, mkbuiltins, ov-base-diag.h, ov-base-int.cc, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-bool-mat.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-colon.cc, ov-complex.cc, ov-cs-list.h, ov-cx-mat.cc, ov-dld-fcn.cc, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.h, ov-mex-fcn.cc, ov-perm.h, ov-range.cc, ov-re-mat.cc, ov-scalar.cc, ov-str-mat.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, octave.cc, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-double-conv.cc, op-fcdm-fcdm.cc, op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int-conv.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, parse.h, pt-arg-list.cc, pt-assign.cc, pt-binop.cc, pt-cbinop.cc, pt-cell.cc, pt-colon.cc, pt-const.cc, pt-eval.h, pt-fcn-handle.cc, pt-funcall.h, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-mat.cc, pt-select.cc, pt-unop.cc, token.cc, Array-sym.cc: replace '#include "oct-obj.h"' with '#include "ovl.h"'.
author Rik <rik@octave.org>
date Fri, 18 Dec 2015 16:04:56 -0800
parents 1142cf6abc0d
children 49852ff04747
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1 /*
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 18605
diff changeset
3 Copyright (C) 2002-2015 Kai Habel
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11518
diff changeset
4 Copyright (C) 2008-2009 Jaroslav Hajek
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
5
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
7
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
11 option) any later version.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
12
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
16 for more details.
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
17
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
20 <http://www.gnu.org/licenses/>.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
21
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
22 */
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
23
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
25 #include <config.h>
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
26 #endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
27
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14846
diff changeset
28 #include "defun.h"
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
29 #include "error.h"
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
30 #include "gripes.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20853
diff changeset
31 #include "ovl.h"
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
32 #include "utils.h"
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
33 #include "f77-fcn.h"
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
34
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
35 extern "C"
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
36 {
6242
64bad7c6a607 [project @ 2007-01-16 07:03:51 by jwe]
jwe
parents: 5838
diff changeset
37 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10154
diff changeset
38 F77_FUNC (dpchim, DPCHIM) (const octave_idx_type& n, const double *x,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10154
diff changeset
39 const double *f, double *d,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10154
diff changeset
40 const octave_idx_type &incfd,
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
41 octave_idx_type *ierr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
42
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
43 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10154
diff changeset
44 F77_FUNC (pchim, PCHIM) (const octave_idx_type& n, const float *x,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10154
diff changeset
45 const float *f, float *d,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10154
diff changeset
46 const octave_idx_type& incfd,
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
47 octave_idx_type *ierr);
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
48 }
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
49
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6549
diff changeset
50 // Wrapper for SLATEC/PCHIP function DPCHIM to calculate the derivates
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6549
diff changeset
51 // for piecewise polynomials.
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6549
diff changeset
52
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14846
diff changeset
53 DEFUN (__pchip_deriv__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
54 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
55 @deftypefn {} {} __pchip_deriv__ (@var{x}, @var{y}, @var{dim})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6549
diff changeset
56 Undocumented internal function.\n\
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
57 @end deftypefn")
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
58 {
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
59 octave_value retval;
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
60 const int nargin = args.length ();
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
61
18112
b560bac0fca2 maint: Don't use space between 'args' and '(' when doing indexing.
Rik <rik@octave.org>
parents: 17787
diff changeset
62 bool rows = (nargin == 3 && args(2).uint_value () == 2);
8712
010e15c7be9a support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
63
010e15c7be9a support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
64 if (nargin >= 2)
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
65 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
66 if (args(0).is_single_type () || args(1).is_single_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
67 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
68 FloatColumnVector xvec (args(0).float_vector_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
69 FloatMatrix ymat (args(1).float_matrix_value ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
70
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19873
diff changeset
71 octave_idx_type nx = xvec.numel ();
14462
af552038cc52 Fix segfault in pchip when input array is too small (bug #35835).
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
72
af552038cc52 Fix segfault in pchip when input array is too small (bug #35835).
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
73 if (nx < 2)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
74 error ("__pchip_deriv__: X must be at least of length 2");
14462
af552038cc52 Fix segfault in pchip when input array is too small (bug #35835).
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
75
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
76 octave_idx_type nyr = ymat.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
77 octave_idx_type nyc = ymat.columns ();
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
78
8712
010e15c7be9a support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
79 if (nx != (rows ? nyc : nyr))
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
80 error ("__pchip_deriv__: X and Y dimension mismatch");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
81
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
82 FloatMatrix dmat (nyr, nyc);
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
83
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
84 octave_idx_type ierr;
8712
010e15c7be9a support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
85 const octave_idx_type incfd = rows ? nyr : 1;
19787
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
86 volatile const octave_idx_type inc = rows ? 1 : nyr;
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
87 volatile octave_idx_type k = 0;
8712
010e15c7be9a support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
88
19873
5261186f1b00 __pchip_deriv__.cc: Stop variable might be clobbered by 'longjmp' warning.
Rik <rik@octave.org>
parents: 19787
diff changeset
89 for (volatile octave_idx_type i = (rows ? nyr : nyc); i > 0; i--)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
90 {
18603
e7369c43ebe0 Fix segmentation fault for interp2 and pchip method (bug #41838).
Stefan Mahr <dac922@gmx.de>
parents: 17787
diff changeset
91 F77_XFCN (pchim, PCHIM, (nx, xvec.data (),
19787
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
92 ymat.data () + k * inc,
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
93 dmat.fortran_vec () + k * inc,
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
94 incfd, &ierr));
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
95
19787
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
96 k++;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
97
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
98 if (ierr < 0)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
99 error ("__pchip_deriv__: PCHIM failed with ierr = %i", ierr);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
100 }
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
101
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
102 retval = dmat;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
103 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
104 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
105 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
106 ColumnVector xvec (args(0).vector_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
107 Matrix ymat (args(1).matrix_value ());
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
108
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19873
diff changeset
109 octave_idx_type nx = xvec.numel ();
14462
af552038cc52 Fix segfault in pchip when input array is too small (bug #35835).
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
110
af552038cc52 Fix segfault in pchip when input array is too small (bug #35835).
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
111 if (nx < 2)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
112 error ("__pchip_deriv__: X must be at least of length 2");
14462
af552038cc52 Fix segfault in pchip when input array is too small (bug #35835).
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
113
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
114 octave_idx_type nyr = ymat.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
115 octave_idx_type nyc = ymat.columns ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
116
8712
010e15c7be9a support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
117 if (nx != (rows ? nyc : nyr))
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
118 error ("__pchip_deriv__: X and Y dimension mismatch");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
119
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
120 Matrix dmat (nyr, nyc);
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
121
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
122 octave_idx_type ierr;
8712
010e15c7be9a support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
123 const octave_idx_type incfd = rows ? nyr : 1;
19787
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
124 volatile const octave_idx_type inc = rows ? 1 : nyr;
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
125 volatile octave_idx_type k = 0;
8712
010e15c7be9a support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
126
19873
5261186f1b00 __pchip_deriv__.cc: Stop variable might be clobbered by 'longjmp' warning.
Rik <rik@octave.org>
parents: 19787
diff changeset
127 for (volatile octave_idx_type i = (rows ? nyr : nyc); i > 0; i--)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
128 {
18603
e7369c43ebe0 Fix segmentation fault for interp2 and pchip method (bug #41838).
Stefan Mahr <dac922@gmx.de>
parents: 17787
diff changeset
129 F77_XFCN (dpchim, DPCHIM, (nx, xvec.data (),
19787
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
130 ymat.data () + k * inc,
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
131 dmat.fortran_vec () + k * inc,
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
132 incfd, &ierr));
4ae2987c5f66 avoid variable possibly clobbered by longjmp warning from GCC
John W. Eaton <jwe@octave.org>
parents: 19780
diff changeset
133 k++;
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
134
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
135 if (ierr < 0)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
136 error ("__pchip_deriv__: DPCHIM failed with ierr = %i", ierr);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
137 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
138
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
139 retval = dmat;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 8713
diff changeset
140 }
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
141 }
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
142
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
143 return retval;
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
144 }
12805
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
145
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
146 /*
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
147 ## No test needed for internal helper function.
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
148 %!assert (1)
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
149 */