GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
array
Array-fC.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 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
39
sort_isnan<FloatComplex>
(
const
FloatComplex
&
x
)
40
{
41
return
xisnan
(
x
);
42
}
43
44
static
bool
45
nan_ascending_compare
(
const
FloatComplex
&
x
,
const
FloatComplex
& y)
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
54
nan_descending_compare
(
const
FloatComplex
&
x
,
const
FloatComplex
& y)
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
62
Array<FloatComplex>::compare_fcn_type
63
safe_comparator
(
sortmode
mode,
const
Array<FloatComplex>
& a,
bool
allow_chk)
64
{
65
Array<FloatComplex>::compare_fcn_type
result = 0;
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
)
74
result =
octave_sort<FloatComplex>::ascending_compare
;
75
else
if
(mode ==
DESCENDING
)
76
result =
octave_sort<FloatComplex>::descending_compare
;
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
91
INSTANTIATE_ARRAY_SORT
(
FloatComplex
);
92
93
INSTANTIATE_ARRAY
(
FloatComplex
, OCTAVE_API);
94
95
template
OCTAVE_API std::ostream&
operator <<
(std::ostream&,
96
const
Array<FloatComplex>
&);
97
98
#include "
DiagArray2.h
"
99
#include "
DiagArray2.cc
"
100
101
template
class
OCTAVE_API
DiagArray2<FloatComplex>
;
Generated on Mon Dec 30 2013 03:04:38 for GNU Octave by
1.8.1.2