annotate liboctave/array/Array-b.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 538b57866b90
children f7d1050b9b53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2493
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
1 /*
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 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) 1996-2015 John W. Eaton
2493
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
4
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
6
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
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: 6708
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: 6708
diff changeset
10 option) any later version.
2493
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
11
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
15 for more details.
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
16
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
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: 6708
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: 6708
diff changeset
19 <http://www.gnu.org/licenses/>.
2493
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
20
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
21 */
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
22
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 21139
diff changeset
24 # include <config.h>
2493
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
25 #endif
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
26
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
27 // Instantiate Arrays of bool values.
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
28
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
29 #include "Array.h"
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
30 #include "Array.cc"
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
31 #define INLINE_ASCENDING_SORT
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
32 #define INLINE_DESCENDING_SORT
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
33 #include "oct-sort.cc"
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
34
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
35 // Specialize bool sorting (aka stable partitioning).
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
36
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
37 template <bool desc>
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
38 static void do_bool_partition (bool *data, octave_idx_type nel)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
39 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
40 octave_idx_type k = 0;
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
41 for (octave_idx_type i = 0; i < nel; i++)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
42 if (data[i] == desc)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
43 data[k++] = desc;
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
44 for (octave_idx_type i = k; i < nel; i++)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
45 data[i] = ! desc;
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
46 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
47
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
48 template <bool desc>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
49 static void do_bool_partition (bool *data, octave_idx_type *idx,
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
50 octave_idx_type nel)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
51 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
52 // FIXME: This is essentially a simple bucket sort.
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
53 // Can it be efficiently done by std::partition?
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
54 OCTAVE_LOCAL_BUFFER (octave_idx_type, jdx, nel);
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
55 octave_idx_type k = 0;
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
56 octave_idx_type l = 0;
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
57 for (octave_idx_type i = 0; i < nel; i++)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
58 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
59 if (data[i] == desc)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
60 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
61 data[k] = desc;
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
62 idx[k++] = idx[i];
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
63 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
64 else
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
65 jdx[l++] = idx[i];
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
66 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
67
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
68 for (octave_idx_type i = k; i < nel; i++)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
69 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
70 data[i] = ! desc;
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
71 idx[i] = jdx[i-k];
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
72 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
73 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
74
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
75 template <>
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
76 template <>
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
77 void
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
78 octave_sort<bool>::sort (bool *data, octave_idx_type nel,
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
79 std::less<bool>)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
80 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
81 do_bool_partition<false> (data, nel);
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
82 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
83
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
84 template <>
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
85 template <>
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
86 void
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
87 octave_sort<bool>::sort (bool *data, octave_idx_type nel,
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
88 std::greater<bool>)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
89 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
90 do_bool_partition<true> (data, nel);
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
91 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
92
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
93 template <>
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
94 template <>
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
95 void
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
96 octave_sort<bool>::sort (bool *data, octave_idx_type *idx, octave_idx_type nel,
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
97 std::less<bool>)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
98 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
99 do_bool_partition<false> (data, idx, nel);
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
100 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
101
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
102 template <>
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
103 template <>
10114
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
104 void
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
105 octave_sort<bool>::sort (bool *data, octave_idx_type *idx, octave_idx_type nel,
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
106 std::greater<bool>)
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
107 {
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
108 do_bool_partition<true> (data, idx, nel);
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
109 }
e4936c129cbd optimize sorting of bools
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
110
19395
fb09907f4e49 Remove single line makro INSTANTIATE_ARRAY_SORT.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 18084
diff changeset
111 template class OCTAVE_API octave_sort<bool>;
2493
8ed4362aa0d6 [project @ 1996-11-11 02:35:04 by jwe]
jwe
parents:
diff changeset
112
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7433
diff changeset
113 INSTANTIATE_ARRAY (bool, OCTAVE_API);
3836
b8c1cb5b9fd9 [project @ 2001-05-31 19:30:49 by jwe]
jwe
parents: 3176
diff changeset
114
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
115 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
116 const Array<bool>&);
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 3836
diff changeset
117
2826
d6867cd782c7 [project @ 1997-03-25 23:36:39 by jwe]
jwe
parents: 2493
diff changeset
118 #include "DiagArray2.h"
d6867cd782c7 [project @ 1997-03-25 23:36:39 by jwe]
jwe
parents: 2493
diff changeset
119 #include "DiagArray2.cc"
d6867cd782c7 [project @ 1997-03-25 23:36:39 by jwe]
jwe
parents: 2493
diff changeset
120
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5307
diff changeset
121 template class OCTAVE_API DiagArray2<bool>;