GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Array-C.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2013 John W. Eaton
4 Copyright (C) 2009 VZLU Prague
5 
6 This file is part of Octave.
7 
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 // Instantiate Arrays of Complex values.
29 
30 #include "oct-cmplx.h"
31 #include "lo-mappers.h"
32 
33 #include "Array.h"
34 #include "Array.cc"
35 #include "oct-sort.cc"
36 
37 template <>
38 inline bool
40 {
41  return xisnan (x);
42 }
43 
44 static bool
46 {
47  return (xisnan (y)
48  ? ! xisnan (x)
49  : ((std::abs (x) < std::abs (x))
50  || ((std::abs (x) == std::abs (x)) && (arg (x) < arg (x)))));
51 }
52 
53 static bool
55 {
56  return (xisnan (x)
57  ? ! xisnan (y)
58  : ((std::abs (x) > std::abs (x))
59  || ((std::abs (x) == std::abs (x)) && (arg (x) > arg (x)))));
60 }
61 
63 safe_comparator (sortmode mode, const Array<Complex>& a , bool allow_chk)
64 {
66 
67  if (allow_chk)
68  {
69  octave_idx_type k = 0;
70  for (; k < a.numel () && ! xisnan (a(k)); k++) ;
71  if (k == a.numel ())
72  {
73  if (mode == ASCENDING)
75  else if (mode == DESCENDING)
77  }
78  }
79 
80  if (! result)
81  {
82  if (mode == ASCENDING)
83  result = nan_ascending_compare;
84  else if (mode == DESCENDING)
85  result = nan_descending_compare;
86  }
87 
88  return result;
89 }
90 
92 
93 INSTANTIATE_ARRAY (Complex, OCTAVE_API);
94 
95 template OCTAVE_API std::ostream& operator << (std::ostream&,
96  const Array<Complex>&);
97 
98 #include "DiagArray2.h"
99 #include "DiagArray2.cc"
100 
101 template class OCTAVE_API DiagArray2<Complex>;