annotate liboctave/array/Array-C.cc @ 27919:1891570abac8

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2020.
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 22:29:51 -0500
parents b442ec6dda5c
children bd51beb6205e
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
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 Copyright (C) 1994-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
5 See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
6 or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
7
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
8
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
9 This file is part of Octave.
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
10
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
11 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
13 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 (at your option) any later version.
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
15
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
16 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
17 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
19 GNU General Public License for more details.
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
20
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
21 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
22 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
23 <https://www.gnu.org/licenses/>.
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
24
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
25 */
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
26
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21574
diff changeset
27 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
28 # include "config.h"
2006
95e952f72d66 [project @ 1996-03-04 00:33:32 by jwe]
jwe
parents: 1993
diff changeset
29 #endif
95e952f72d66 [project @ 1996-03-04 00:33:32 by jwe]
jwe
parents: 1993
diff changeset
30
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
31 // Instantiate Arrays of Complex values.
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
32
1989
a4b0826e240c [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents: 1882
diff changeset
33 #include "oct-cmplx.h"
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
34 #include "lo-mappers.h"
1989
a4b0826e240c [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents: 1882
diff changeset
35
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
36 #include "Array.h"
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
37 #include "Array.cc"
8700
314be237cd5b sorting optimizations
Jaroslav Hajek <highegg@gmail.com>
parents: 8290
diff changeset
38 #include "oct-sort.cc"
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
39
21573
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19966
diff changeset
40 // Prevent implicit instantiations on some systems (Windows, others?)
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19966
diff changeset
41 // that can lead to duplicate definitions of static data members.
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19966
diff changeset
42
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19966
diff changeset
43 extern template class OCTAVE_API Array<idx_vector>;
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19966
diff changeset
44 extern template class OCTAVE_API Array<octave_idx_type>;
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19966
diff changeset
45
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
46 template <>
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
47 inline bool
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
48 sort_isnan<Complex> (const Complex& x)
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
49 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
50 return octave::math::isnan (x);
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
51 }
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
52
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19633
diff changeset
53 // Sort Criteria: 1) isnan, 2) magnitude of z, 3) phase of z in range (-pi, pi]
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19633
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 (const Complex& x, const Complex& y)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
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: 8700
diff changeset
59 }
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 static bool
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
62 nan_descending_compare (const Complex& x, const Complex& y)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
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: 8700
diff changeset
65 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
66
8725
d5af326a3ede [mq]: sort-traits
John W. Eaton <jwe@octave.org>
parents: 8721
diff changeset
67 Array<Complex>::compare_fcn_type
9920
56fbe170d354 fix issorted with NaNs in middle
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
68 safe_comparator (sortmode mode, const Array<Complex>& a , bool allow_chk)
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
69 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23220
diff changeset
70 Array<Complex>::compare_fcn_type result = nullptr;
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
71
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
72 if (allow_chk)
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 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: 8700
diff changeset
76 if (k == a.numel ())
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 = octave_sort<Complex>::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 = octave_sort<Complex>::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
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
85 if (! result)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
86 {
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
87 if (mode == ASCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
88 result = nan_ascending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
89 else if (mode == DESCENDING)
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
90 result = nan_descending_compare;
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
91 }
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
92
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
93 return result;
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
94 }
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7017
diff changeset
95
19395
fb09907f4e49 Remove single line makro INSTANTIATE_ARRAY_SORT.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17769
diff changeset
96 template class OCTAVE_API octave_sort<Complex>;
757
b75705dec035 [project @ 1994-10-02 15:19:39 by jwe]
jwe
parents:
diff changeset
97
8721
e9cb742df9eb imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8700
diff changeset
98 INSTANTIATE_ARRAY (Complex, OCTAVE_API);
3836
b8c1cb5b9fd9 [project @ 2001-05-31 19:30:49 by jwe]
jwe
parents: 3164
diff changeset
99
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
100 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
101 const Array<Complex>&);
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 3836
diff changeset
102
1989
a4b0826e240c [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents: 1882
diff changeset
103 #include "DiagArray2.h"
a4b0826e240c [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents: 1882
diff changeset
104 #include "DiagArray2.cc"
a4b0826e240c [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents: 1882
diff changeset
105
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5307
diff changeset
106 template class OCTAVE_API DiagArray2<Complex>;