Mercurial > octave
annotate src/DLD-FUNCTIONS/__pchip_deriv__.cc @ 12805:3641167e5b75
codesprint: *.cc helper functions do not need tests
* __contourc__.cc, __delaunayn__.cc, __dsearchn__.cc, __fltk_uigetfile__.cc,
__glpk__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc,
__qp__.cc, __voronoi__.cc: Add %!assert(1) to stop files from reporting no tests
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 16 Jul 2011 11:16:35 -0700 |
parents | 12df7854fa7c |
children | 72c96de7a403 |
rev | line source |
---|---|
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1 /* |
5837 | 2 |
11523 | 3 Copyright (C) 2002-2011 Kai Habel |
4 Copyright (C) 2008-2009 Jaroslav Hajek | |
5837 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5837 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5837 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include "defun-dld.h" | |
29 #include "error.h" | |
30 #include "gripes.h" | |
31 #include "oct-obj.h" | |
32 #include "utils.h" | |
33 #include "f77-fcn.h" | |
34 | |
5838 | 35 extern "C" |
36 { | |
6242 | 37 F77_RET_T |
11518 | 38 F77_FUNC (dpchim, DPCHIM) (const octave_idx_type& n, const double *x, |
39 const double *f, double *d, | |
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 | 44 F77_FUNC (pchim, PCHIM) (const octave_idx_type& n, const float *x, |
45 const float *f, float *d, | |
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 | 48 } |
49 | |
6945 | 50 // Wrapper for SLATEC/PCHIP function DPCHIM to calculate the derivates |
51 // for piecewise polynomials. | |
52 | |
6549 | 53 DEFUN_DLD (__pchip_deriv__, args, , |
5837 | 54 "-*- texinfo -*-\n\ |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
55 @deftypefn {Loadable Function} {} __pchip_deriv__ (@var{x}, @var{y}, @var{dim})\n\ |
6945 | 56 Undocumented internal function.\n\ |
5837 | 57 @end deftypefn") |
58 { | |
59 octave_value retval; | |
5838 | 60 const int nargin = args.length (); |
5837 | 61 |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
62 bool rows = (nargin == 3 && args (2).uint_value() == 2); |
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 | 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 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
71 octave_idx_type nx = xvec.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
72 octave_idx_type nyr = ymat.rows (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
73 octave_idx_type nyc = ymat.columns (); |
5838 | 74 |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
75 if (nx != (rows ? nyc : nyr)) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
76 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
77 error ("__pchip_deriv__: X and Y dimension mismatch"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
78 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
79 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
80 |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
81 const float *yvec = ymat.data (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
82 FloatMatrix dmat (nyr, nyc); |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
83 float *dvec = dmat.fortran_vec (); |
5837 | 84 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
85 octave_idx_type ierr; |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
86 const octave_idx_type incfd = rows ? nyr : 1; |
8713
02d4c764de61
fix typo in previous patch
Jaroslav Hajek <highegg@gmail.com>
parents:
8712
diff
changeset
|
87 const octave_idx_type inc = rows ? 1 : nyr; |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
88 |
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
89 for (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 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
91 F77_FUNC (pchim, PCHIM) (nx, xvec.data (), |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
92 yvec, dvec, incfd, &ierr); |
5837 | 93 |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
94 yvec += inc; |
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
95 dvec += inc; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
96 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
97 if (ierr < 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
98 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
99 error ("PCHIM: error: %i\n", ierr); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
100 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
101 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
102 } |
5837 | 103 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
104 retval = dmat; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
105 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
106 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
107 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
108 ColumnVector xvec (args(0).vector_value ()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
109 Matrix ymat (args(1).matrix_value ()); |
5837 | 110 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
111 octave_idx_type nx = xvec.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
112 octave_idx_type nyr = ymat.rows (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
113 octave_idx_type nyc = ymat.columns (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
114 |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
115 if (nx != (rows ? nyc : nyr)) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
116 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
117 error ("__pchip_deriv__: X and Y dimension mismatch"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
118 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
119 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
120 |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
121 const double *yvec = ymat.data (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
122 Matrix dmat (nyr, nyc); |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
123 double *dvec = dmat.fortran_vec (); |
5837 | 124 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
125 octave_idx_type ierr; |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
126 const octave_idx_type incfd = rows ? nyr : 1; |
8713
02d4c764de61
fix typo in previous patch
Jaroslav Hajek <highegg@gmail.com>
parents:
8712
diff
changeset
|
127 const octave_idx_type inc = rows ? 1 : nyr; |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
128 |
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
129 for (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
|
130 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
131 F77_FUNC (dpchim, DPCHIM) (nx, xvec.data (), |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
132 yvec, dvec, incfd, &ierr); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
133 |
8712
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
134 yvec += inc; |
010e15c7be9a
support pchip method in interp2
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
135 dvec += inc; |
5838 | 136 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
137 if (ierr < 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
138 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
139 error ("DPCHIM: error: %i\n", ierr); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
140 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
141 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
142 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
143 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
144 retval = dmat; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
8713
diff
changeset
|
145 } |
5837 | 146 } |
147 | |
148 return retval; | |
149 } | |
12805
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
150 |
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
151 /* |
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
152 |
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
153 ## 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
|
154 %!assert (1) |
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
155 |
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
156 */ |