annotate liboctave/array/Array-d.cc @ 21202:f7121e111991

maint: indent #ifdef blocks in liboctave and src directories. * Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, CSparse.h, DiagArray2.cc, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MSparse.h, MatrixType.cc, PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, dSparse.h, dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc, int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, intNDArray.cc, uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc, blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, quit.cc, quit.h, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc, CmplxQR.cc, CmplxQRP.cc, CmplxSCHUR.cc, CmplxSVD.cc, CollocWt.cc, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, base-lu.cc, base-qr.cc, dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc, dbleQRP.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc, fCmplxCHOL.cc, fCmplxGEPBAL.cc, fCmplxHESS.cc, fCmplxLU.cc, fCmplxQR.cc, fCmplxQRP.cc, fCmplxSCHUR.cc, fCmplxSVD.cc, fEIG.cc, floatAEPBAL.cc, floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc, floatQRP.cc, floatSCHUR.cc, floatSVD.cc, lo-mappers.cc, lo-specfun.cc, oct-convn.cc, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-rand.cc, oct-spparms.cc, randgamma.c, randmtzig.c, randpoisson.c, sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, mx-defs.h, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-group.cc, oct-openmp.h, oct-passwd.cc, oct-syscalls.cc, oct-time.cc, oct-uname.cc, pathlen.h, sysdir.h, syswait.h, cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c, glob-match.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c, lo-cutils.h, lo-ieee.cc, lo-math.h, lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.cc, oct-mutex.cc, oct-refcount.h, oct-rl-edit.c, oct-rl-hist.c, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc, sparse-sort.cc, sparse-util.cc, statdefs.h, str-vec.cc, unwind-prot.cc, url-transfer.cc, display-available.h, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-config.in.cc, shared-fcns.h: indent #ifdef blocks in liboctave and src directories.
author Rik <rik@octave.org>
date Sat, 06 Feb 2016 06:40:13 -0800
parents 4197fc428c7d
children f7d1050b9b53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
1 /*
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19395
diff changeset
3 Copyright (C) 1994-2015 John W. Eaton
10521
4d1fc073fbb7 add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents: 10374
diff changeset
4 Copyright (C) 2009 VZLU Prague
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
5
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
7
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
b75705dec035 [project @ 1994-10-02 15:19:39 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: 6708
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: 6708
diff changeset
11 option) any later version.
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
12
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
16 for more details.
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
17
b75705dec035 [project @ 1994-10-02 15:19:39 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: 6708
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: 6708
diff changeset
20 <http://www.gnu.org/licenses/>.
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
21
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
22 */
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
23
2006
95e952f72d66 [project @ 1996-03-04 00:33:32 by jwe]
jwe
parents: 1993
diff changeset
24 #ifdef HAVE_CONFIG_H
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 19697
diff changeset
25 # include <config.h>
2006
95e952f72d66 [project @ 1996-03-04 00:33:32 by jwe]
jwe
parents: 1993
diff changeset
26 #endif
95e952f72d66 [project @ 1996-03-04 00:33:32 by jwe]
jwe
parents: 1993
diff changeset
27
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
28 // Instantiate Arrays of double values.
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
29
9003
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
30 #include "lo-mappers.h"
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
31 #include "Array.h"
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
32 #include "Array.cc"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8290
diff changeset
33 #include "oct-locbuf.h"
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
34
8700
314be237cd5b sorting optimizations
Jaroslav Hajek <highegg@gmail.com>
parents: 8651
diff changeset
35 #define INLINE_ASCENDING_SORT
314be237cd5b sorting optimizations
Jaroslav Hajek <highegg@gmail.com>
parents: 8651
diff changeset
36 #define INLINE_DESCENDING_SORT
314be237cd5b sorting optimizations
Jaroslav Hajek <highegg@gmail.com>
parents: 8651
diff changeset
37 #include "oct-sort.cc"
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
38
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
39 template <>
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
40 inline bool
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
41 sort_isnan<double> (double x)
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
42 {
9003
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
43 return xisnan (x);
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
44 }
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
45
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
46 static bool
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
47 nan_ascending_compare (double x, double y)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
48 {
9003
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
49 return xisnan (y) ? ! xisnan (x) : x < y;
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
50 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
51
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
52 static bool
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
53 nan_descending_compare (double x, double y)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
54 {
9003
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
55 return xisnan (x) ? ! xisnan (y) : x > y;
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
56 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
57
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
58 Array<double>::compare_fcn_type
9920
56fbe170d354 fix issorted with NaNs in middle
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
59 safe_comparator (sortmode mode, const Array<double>& a , bool allow_chk)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
60 {
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
61 Array<double>::compare_fcn_type result = 0;
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
62
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
63 if (allow_chk)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
64 {
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
65 octave_idx_type k = 0;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
66 for (; k < a.numel () && ! xisnan (a(k)); k++) ;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
67 if (k == a.numel ())
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
68 {
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
69 if (mode == ASCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
70 result = octave_sort<double>::ascending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
71 else if (mode == DESCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
72 result = octave_sort<double>::descending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
73 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
74 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
75
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
76 if (! result)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
77 {
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
78 if (mode == ASCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
79 result = nan_ascending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
80 else if (mode == DESCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
81 result = nan_descending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
82 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
83
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
84 return result;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
85 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
86
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
87 // The default solution using NaN-safe comparator is OK, but almost twice as
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
88 // slow than this code.
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
89 template <>
9941
1369f13ae6b2 several fixes by M. Goffioul
Jaroslav Hajek <highegg@gmail.com>
parents: 9922
diff changeset
90 OCTAVE_API
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
91 sortmode
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
92 Array<double>::is_sorted (sortmode mode) const
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
93 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
94 octave_idx_type n = numel ();
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
95
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
96 const double *el = data ();
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
97
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
98 if (n <= 1)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
99 return mode ? mode : ASCENDING;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
100
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
101 if (! mode)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
102 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
103 // Auto-detect mode.
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
104 if (el[n-1] < el[0] || xisnan (el[0]))
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
105 mode = DESCENDING;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
106 else
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
107 mode = ASCENDING;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
108 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
109
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
110 if (mode == DESCENDING)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
111 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
112 octave_idx_type j = 0;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
113 double r;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
114 // Sort out NaNs.
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
115 do
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
116 r = el[j++];
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
117 while (xisnan (r) && j < n);
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
118
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
119 // Orient the test so that NaN will not pass through.
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
120 for (; j < n; j++)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
121 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
122 if (r >= el[j])
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
123 r = el[j];
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
124 else
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
125 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
126 mode = UNSORTED;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
127 break;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
128 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
129 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
130
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
131 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
132 else if (mode == ASCENDING)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
133 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
134 // Sort out NaNs.
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
135 while (n > 0 && xisnan (el[n-1]))
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
136 n--;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
137
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
138 if (n > 0)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
139 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
140 // Orient the test so that NaN will not pass through.
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
141 double r = el[0];
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
142 for (octave_idx_type j = 1; j < n; j++)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
143 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
144 if (r <= el[j])
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
145 r = el[j];
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
146 else
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
147 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
148 mode = UNSORTED;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
149 break;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
150 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
151 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
152 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
153 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
154
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
155 return mode;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
156 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
157
19395
fb09907f4e49 Remove single line makro INSTANTIATE_ARRAY_SORT.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17769
diff changeset
158 template class OCTAVE_API octave_sort<double>;
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
159
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
160 INSTANTIATE_ARRAY (double, OCTAVE_API);
3836
b8c1cb5b9fd9 [project @ 2001-05-31 19:30:49 by jwe]
jwe
parents: 3665
diff changeset
161
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
162 template OCTAVE_API std::ostream& operator << (std::ostream&,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
163 const Array<double>&);
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3164
diff changeset
164
1989
a4b0826e240c [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents: 1882
diff changeset
165 #include "DiagArray2.h"
a4b0826e240c [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents: 1882
diff changeset
166 #include "DiagArray2.cc"
a4b0826e240c [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents: 1882
diff changeset
167
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5307
diff changeset
168 template class OCTAVE_API DiagArray2<double>;