GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Array-C.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2018 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
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License 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 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (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 // Prevent implicit instantiations on some systems (Windows, others?)
38 // that can lead to duplicate definitions of static data members.
39 
40 extern template class OCTAVE_API Array<idx_vector>;
41 extern template class OCTAVE_API Array<octave_idx_type>;
42 
43 template <>
44 inline bool
46 {
47  return octave::math::isnan (x);
48 }
49 
50 // Sort Criteria: 1) isnan, 2) magnitude of z, 3) phase of z in range (-pi, pi]
51 
52 static bool
54 {
55  return octave::math::isnan (y) ? ! octave::math::isnan (x) : x < y;
56 }
57 
58 static bool
60 {
61  return octave::math::isnan (x) ? ! octave::math::isnan (y) : x > y;
62 }
63 
65 safe_comparator (sortmode mode, const Array<Complex>& a , bool allow_chk)
66 {
68 
69  if (allow_chk)
70  {
71  octave_idx_type k = 0;
72  for (; k < a.numel () && ! octave::math::isnan (a(k)); k++) ;
73  if (k == a.numel ())
74  {
75  if (mode == ASCENDING)
77  else if (mode == DESCENDING)
79  }
80  }
81 
82  if (! result)
83  {
84  if (mode == ASCENDING)
86  else if (mode == DESCENDING)
88  }
89 
90  return result;
91 }
92 
93 template class OCTAVE_API octave_sort<Complex>;
94 
95 INSTANTIATE_ARRAY (Complex, OCTAVE_API);
96 
97 template OCTAVE_API std::ostream& operator << (std::ostream&,
98  const Array<Complex>&);
99 
100 #include "DiagArray2.h"
101 #include "DiagArray2.cc"
102 
103 template class OCTAVE_API DiagArray2<Complex>;
static bool nan_descending_compare(const Complex &x, const Complex &y)
Definition: Array-C.cc:59
Array< Complex >::compare_fcn_type safe_comparator(sortmode mode, const Array< Complex > &a, bool allow_chk)
Definition: Array-C.cc:65
sortmode
Definition: oct-sort.h:105
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6348
for large enough k
Definition: lu.cc:617
bool isnan(bool)
Definition: lo-mappers.h:187
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
#define INSTANTIATE_ARRAY(T, API)
Definition: Array.cc:2768
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< Complex > &)
With real return the complex result
Definition: data.cc:3260
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:125
bool sort_isnan< Complex >(const Complex &x)
Definition: Array-C.cc:45
the element is set to zero In other the statement xample y
Definition: data.cc:5264
static bool nan_ascending_compare(const Complex &x, const Complex &y)
Definition: Array-C.cc:53
std::complex< double > Complex
Definition: oct-cmplx.h:31
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x