GNU Octave  4.0.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-fC.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2015 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 FloatComplex 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 // Sort Criteria: 1) isnan, 2) magnitude of z, 3) phase of z in range (-pi, pi]
45 
46 static bool
48 {
49  return xisnan (y) ? ! xisnan (x) : x < y;
50 }
51 
52 static bool
54 {
55  return xisnan (x) ? ! xisnan (y) : x > y;
56 }
57 
59 safe_comparator (sortmode mode, const Array<FloatComplex>& a, bool allow_chk)
60 {
62 
63  if (allow_chk)
64  {
65  octave_idx_type k = 0;
66  for (; k < a.numel () && ! xisnan (a(k)); k++) ;
67  if (k == a.numel ())
68  {
69  if (mode == ASCENDING)
71  else if (mode == DESCENDING)
73  }
74  }
75 
76  if (! result)
77  {
78  if (mode == ASCENDING)
79  result = nan_ascending_compare;
80  else if (mode == DESCENDING)
81  result = nan_descending_compare;
82  }
83 
84  return result;
85 }
86 
87 template class OCTAVE_API octave_sort<FloatComplex>;
88 
90 
91 template OCTAVE_API std::ostream& operator << (std::ostream&,
92  const Array<FloatComplex>&);
93 
94 #include "DiagArray2.h"
95 #include "DiagArray2.cc"
96 
97 template class OCTAVE_API DiagArray2<FloatComplex>;
bool xisnan(double x)
Definition: lo-mappers.cc:144
sortmode
Definition: oct-sort.h:103
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:275
Array< FloatComplex >::compare_fcn_type safe_comparator(sortmode mode, const Array< FloatComplex > &a, bool allow_chk)
Definition: Array-fC.cc:59
static bool nan_descending_compare(const FloatComplex &x, const FloatComplex &y)
Definition: Array-fC.cc:53
static bool nan_ascending_compare(const FloatComplex &x, const FloatComplex &y)
Definition: Array-fC.cc:47
bool sort_isnan< FloatComplex >(const FloatComplex &x)
Definition: Array-fC.cc:39
#define INSTANTIATE_ARRAY(T, API)
Definition: Array.cc:2773
Handles the reference counting for all the derived classes.
Definition: Array.h:45
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< FloatComplex > &)
std::complex< float > FloatComplex
Definition: oct-cmplx.h:30
F77_RET_T const double * x