annotate liboctave/array/Array-f.cc @ 31606:dfa5d9c3ae72

maint: merge stable to default
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 14:28:07 -0800
parents e7fc6251b698
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29569
diff changeset
3 // Copyright (C) 1994-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21574
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21213
diff changeset
27 # include "config.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
28 #endif
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
29
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
30 // Instantiate Arrays of float values.
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
31
9003
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
32 #include "lo-mappers.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 #include "Array.h"
31400
e7fc6251b698 Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31396
diff changeset
34
e7fc6251b698 Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31396
diff changeset
35 // Prevent implicit instantiations on some systems (Windows, others?)
e7fc6251b698 Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31396
diff changeset
36 // that can lead to duplicate definitions of static data members.
e7fc6251b698 Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31396
diff changeset
37
e7fc6251b698 Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31396
diff changeset
38 extern template class OCTAVE_EXTERN_TEMPLATE_API Array<octave::idx_vector>;
e7fc6251b698 Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31396
diff changeset
39 extern template class Array<octave_idx_type>;
e7fc6251b698 Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31396
diff changeset
40
31396
7e60506a5428 Prevent implicit instantiations of the Array class template (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
41 #include "Array-base.cc"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8290
diff changeset
42 #include "oct-locbuf.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
43
21213
f7d1050b9b53 maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents: 21202
diff changeset
44 #define INLINE_ASCENDING_SORT 1
f7d1050b9b53 maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents: 21202
diff changeset
45 #define INLINE_DESCENDING_SORT 1
8700
314be237cd5b sorting optimizations
Jaroslav Hajek <highegg@gmail.com>
parents: 8651
diff changeset
46 #include "oct-sort.cc"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
47
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
48 template <>
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
49 inline bool
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
50 sort_isnan<float> (float x)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
51 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
52 return octave::math::isnan (x);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
53 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
54
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
55 static bool
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
56 nan_ascending_compare (float x, float y)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
57 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
58 return octave::math::isnan (y) ? ! octave::math::isnan (x) : x < y;
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
59 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
60
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
61 static bool
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
62 nan_descending_compare (float x, float y)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
63 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
64 return octave::math::isnan (x) ? ! octave::math::isnan (y) : x > y;
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
65 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
66
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
67 Array<float>::compare_fcn_type
27933
863ae57eee69 maint: Use Octave coding conventions in liboctave/
Rik <rik@octave.org>
parents: 27923
diff changeset
68 safe_comparator (sortmode mode, const Array<float>& a, bool allow_chk)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
69 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23588
diff changeset
70 Array<float>::compare_fcn_type result = nullptr;
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
71
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
72 if (allow_chk)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
73 {
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
74 octave_idx_type k = 0;
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
75 for (; k < a.numel () && ! octave::math::isnan (a(k)); k++) ;
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
76 if (k == a.numel ())
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
77 {
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
78 if (mode == ASCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
79 result = octave_sort<float>::ascending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
80 else if (mode == DESCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
81 result = octave_sort<float>::descending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
82 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
83 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
84
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
85 if (! result)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
86 {
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
87 if (mode == ASCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
88 result = nan_ascending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
89 else if (mode == DESCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
90 result = nan_descending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
91 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
92
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
93 return result;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
94 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8710
diff changeset
95
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
96 // 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
97 // slow than this code.
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
98 template <>
9941
1369f13ae6b2 several fixes by M. Goffioul
Jaroslav Hajek <highegg@gmail.com>
parents: 9922
diff changeset
99 OCTAVE_API
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
100 sortmode
23588
0549061d35b9 maint: Deprecate is_sorted and replace with issorted.
Rik <rik@octave.org>
parents: 23220
diff changeset
101 Array<float>::issorted (sortmode mode) const
9922
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 octave_idx_type n = numel ();
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
104
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
105 const float *el = data ();
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
106
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
107 if (n <= 1)
26444
5c91daa02f87 Fix static analyzer detected issues with UNSORTED enum (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
108 return (mode == UNSORTED) ? ASCENDING : mode;
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
109
26444
5c91daa02f87 Fix static analyzer detected issues with UNSORTED enum (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
110 if (mode == UNSORTED)
9922
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 // Auto-detect mode.
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
113 if (el[n-1] < el[0] || octave::math::isnan (el[0]))
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
114 mode = DESCENDING;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
115 else
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
116 mode = ASCENDING;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
117 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
118
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
119 if (mode == DESCENDING)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
120 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
121 octave_idx_type j = 0;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
122 float r;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
123 // Sort out NaNs.
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
124 do
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
125 r = el[j++];
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
126 while (octave::math::isnan (r) && j < n);
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
127
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
128 // 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
129 for (; j < n; j++)
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 if (r >= el[j])
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
132 r = el[j];
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
133 else
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
134 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
135 mode = UNSORTED;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
136 break;
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 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
139
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
140 }
26477
310143b2c2c4 Array-d.cc, Array-f.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26444
diff changeset
141 else // mode == ASCENDING
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
142 {
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
143 // Sort out NaNs.
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
144 while (n > 0 && octave::math::isnan (el[n-1]))
9922
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
145 n--;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
146
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
147 if (n > 0)
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
148 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
149 // 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
150 float r = el[0];
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
151 for (octave_idx_type j = 1; j < n; j++)
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 if (r <= el[j])
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
154 r = el[j];
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
155 else
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 mode = UNSORTED;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
158 break;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
159 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
160 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
161 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
162 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
163
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
164 return mode;
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
165 }
3a8327d51ed4 optimize issorted for doubles & floats
Jaroslav Hajek <highegg@gmail.com>
parents: 9920
diff changeset
166
29225
a65ff1d4f75b Remove API tag when instantiating Array template class (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27933
diff changeset
167 template class octave_sort<float>;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
168
31400
e7fc6251b698 Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31396
diff changeset
169 INSTANTIATE_ARRAY (float, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
170
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
171 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
172 const Array<float>&);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
173
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
174 #include "DiagArray2.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
175 #include "DiagArray2.cc"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
176
29225
a65ff1d4f75b Remove API tag when instantiating Array template class (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27933
diff changeset
177 template class DiagArray2<float>;