annotate libinterp/corefcn/__dsearchn__.cc @ 20802:8bb38ba1bad6

eliminate return statements after calls to print_usage * __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __lin_interpn__.cc, __qp__.cc, balance.cc, betainc.cc, bsxfun.cc, colloc.cc, daspk.cc, dasrt.cc, dassl.cc, defaults.cc, det.cc, dlmread.cc, dot.cc, eig.cc, ellipj.cc, fft.cc, fft2.cc, fftn.cc, filter.cc, find.cc, gcd.cc, givens.cc, hex2num.cc, inv.cc, lookup.cc, lu.cc, max.cc, mgorth.cc, ordschur.cc, pinv.cc, profiler.cc, quad.cc, qz.cc, rcond.cc, schur.cc, str2double.cc: Eliminate return statements after calls to print_usage.
author John W. Eaton <jwe@octave.org>
date Fri, 04 Dec 2015 12:03:44 -0500
parents 8742e0b1cc49
children f428cbe7576f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
1 /*
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
3 Copyright (C) 2007-2015 David Bateman
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
4
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
5 This file is part of Octave.
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
6
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
8 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
9 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
10 option) any later version.
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
11
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
15 for more details.
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
16
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
17 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
18 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
19 <http://www.gnu.org/licenses/>.
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
20
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
21 */
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
22
9786
2c279308f6ab fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
23 #ifdef HAVE_CONFIG_H
2c279308f6ab fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
24 #include <config.h>
2c279308f6ab fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
25 #endif
2c279308f6ab fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
26
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
27 #include <iostream>
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
28 #include <fstream>
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
29 #include <string>
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
30
9786
2c279308f6ab fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
31 #include "lo-math.h"
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
32
19877
12ecb7212b44 move some files without external dependencies from dldfcn to corefcn
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
33 #include "defun.h"
9786
2c279308f6ab fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
34 #include "error.h"
2c279308f6ab fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents: 7231
diff changeset
35 #include "oct-obj.h"
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
36
19877
12ecb7212b44 move some files without external dependencies from dldfcn to corefcn
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
37 DEFUN (__dsearchn__, args, ,
12ecb7212b44 move some files without external dependencies from dldfcn to corefcn
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
38 "-*- texinfo -*-\n\
12ecb7212b44 move some files without external dependencies from dldfcn to corefcn
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
39 @deftypefn {Built-in Function} {[@var{idx}, @var{d}] =} dsearch (@var{x}, @var{xi})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6823
diff changeset
40 Undocumented internal function.\n\
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
41 @end deftypefn")
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
42 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
43 int nargin = args.length ();
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
44 octave_value_list retval;
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
45
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
46 if (nargin != 2)
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20667
diff changeset
47 print_usage ();
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
48
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
49 Matrix x = args(0).matrix_value ().transpose ();
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
50 Matrix xi = args(1).matrix_value ().transpose ();
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
51
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
52 if (x.rows () != xi.rows () || x.columns () < 1)
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
53 error ("__dsearch__: number of rows of X and XI must match");
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
54 else
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
55 {
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
56 octave_idx_type n = x.rows ();
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
57 octave_idx_type nx = x.columns ();
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
58 octave_idx_type nxi = xi.columns ();
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
59
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
60 ColumnVector idx (nxi);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
61 double *pidx = idx.fortran_vec ();
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
62 ColumnVector dist (nxi);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
63 double *pdist = dist.fortran_vec ();
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
64
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
65 #define DIST(dd, y, yi, m) \
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
66 dd = 0.; \
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
67 for (octave_idx_type k = 0; k < m; k++) \
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
68 { \
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
69 double yd = y[k] - yi[k]; \
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
70 dd += yd * yd; \
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
71 } \
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
72 dd = sqrt (dd);
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
73
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
74 const double *pxi = xi.fortran_vec ();
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
75 for (octave_idx_type i = 0; i < nxi; i++)
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
76 {
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
77 double d0;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
78 const double *px = x.fortran_vec ();
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
79 DIST(d0, px, pxi, n);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
80 *pidx = 1.;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
81 for (octave_idx_type j = 1; j < nx; j++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9786
diff changeset
82 {
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
83 px += n;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
84 double d;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
85 DIST (d, px, pxi, n);
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
86 if (d < d0)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9786
diff changeset
87 {
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
88 d0 = d;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
89 *pidx = static_cast<double>(j + 1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9786
diff changeset
90 }
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
91 OCTAVE_QUIT;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9786
diff changeset
92 }
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
93
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
94 *pdist++ = d0;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
95 pidx++;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
96 pxi += n;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9786
diff changeset
97 }
20667
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
98
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
99 retval(1) = dist;
8742e0b1cc49 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19877
diff changeset
100 retval(0) = idx;
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
101 }
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
102
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
103 return retval;
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
104 }
12805
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
105
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
106 /*
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
107 ## 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
108 %!assert (1)
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
109 */