Mercurial > octave
annotate liboctave/numeric/lo-mappers.cc @ 23761:102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
* lo-mappers.cc (rc_log2, rc_log10): Use constexpr for pi/ln(2) and pi/ln(10)
constants.
* lo-specfun.cc (rc_log1p): Replace const declaration for pi with M_PI which
comes from <cmath> header file.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 12 Jul 2017 08:01:17 -0700 |
parents | 4c048a2792bc |
children | 4d11ada80395 |
rev | line source |
---|---|
1967 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10459
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
1967 | 5 |
6 This file is part of Octave. | |
7 | |
8 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
|
9 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
10 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
11 (at your option) any later version. |
1967 | 12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
13 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
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
16 GNU General Public License for more details. |
1967 | 17 |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1967 | 21 |
22 */ | |
23 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21232
diff
changeset
|
25 # include "config.h" |
1967 | 26 #endif |
27 | |
28 #include "lo-mappers.h" | |
3121 | 29 #include "lo-specfun.h" |
1967 | 30 |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
31 // FIXME: We used to have this situation: |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
32 // |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
33 // Functions that forward to gnulib belong here so we can keep |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
34 // gnulib:: out of lo-mappers.h. |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
35 // |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
36 // but now we just use std:: and explicit wrappers in C++ code so maybe |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
37 // some of the forwarding functions can be defined inline here. |
11237
110e570e5f8d
keep gnulib out of lo-mappers.h
John W. Eaton <jwe@octave.org>
parents:
11212
diff
changeset
|
38 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
39 namespace octave |
11237
110e570e5f8d
keep gnulib out of lo-mappers.h
John W. Eaton <jwe@octave.org>
parents:
11212
diff
changeset
|
40 { |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
41 namespace math |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
42 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
43 bool |
23619
6ed4d6e306ba
maint: Deprecate is_NA and replace with isna.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
44 isna (double x) |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
45 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
46 return lo_ieee_is_NA (x); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
47 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
48 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
49 bool |
23619
6ed4d6e306ba
maint: Deprecate is_NA and replace with isna.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
50 isna (const Complex& x) |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
51 { |
23619
6ed4d6e306ba
maint: Deprecate is_NA and replace with isna.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
52 return (isna (std::real (x)) || isna (std::imag (x))); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
53 } |
11237
110e570e5f8d
keep gnulib out of lo-mappers.h
John W. Eaton <jwe@octave.org>
parents:
11212
diff
changeset
|
54 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
55 bool |
23619
6ed4d6e306ba
maint: Deprecate is_NA and replace with isna.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
56 isna (float x) |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
57 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
58 return lo_ieee_is_NA (x); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
59 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
60 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
61 bool |
23619
6ed4d6e306ba
maint: Deprecate is_NA and replace with isna.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
62 isna (const FloatComplex& x) |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
63 { |
23619
6ed4d6e306ba
maint: Deprecate is_NA and replace with isna.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
64 return (isna (std::real (x)) || isna (std::imag (x))); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
65 } |
13737
30414ff19d5e
Use copysignf module from gnulib.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
66 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
67 bool |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
68 is_NaN_or_NA (const Complex& x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
69 { |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
70 return (isnan (std::real (x)) || isnan (std::imag (x))); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
71 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 bool |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
74 is_NaN_or_NA (const FloatComplex& x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
75 { |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
76 return (isnan (std::real (x)) || isnan (std::imag (x))); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
77 } |
11525
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
78 |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
79 // Matlab returns a different phase for acos, asin then std library |
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
80 // which requires a small function to remap the phase. |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
81 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
82 acos (const Complex& x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
83 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
84 Complex y = std::acos (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
85 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
86 if (std::imag (x) == 0.0 && std::real (x) > 1.0) |
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
87 return std::conj (y); |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
88 else |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
89 return y; |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
90 } |
11237
110e570e5f8d
keep gnulib out of lo-mappers.h
John W. Eaton <jwe@octave.org>
parents:
11212
diff
changeset
|
91 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
92 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
93 acos (const FloatComplex& x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
94 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
95 FloatComplex y = std::acos (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
96 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
97 if (std::imag (x) == 0.0f && std::real (x) > 1.0f) |
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
98 return std::conj (y); |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
99 else |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
100 return y; |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
101 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
102 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
103 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
104 asin (const Complex& x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
105 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
106 Complex y = std::asin (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
107 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
108 if (std::imag (x) == 0.0 && std::real (x) > 1.0) |
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
109 return std::conj (y); |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
110 else |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
111 return y; |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
112 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
113 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
114 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
115 asin (const FloatComplex& x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
116 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
117 FloatComplex y = std::asin (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
118 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
119 if (std::imag (x) == 0.0f && std::real (x) > 1.0f) |
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22079
diff
changeset
|
120 return std::conj (y); |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
121 else |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
122 return y; |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
123 } |
1967 | 124 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
125 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
126 log2 (const Complex& x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
127 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
128 return std::log (x) / M_LN2; |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
129 } |
5904 | 130 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
131 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
132 log2 (const FloatComplex& x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
133 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
134 return std::log (x) / static_cast<float> (M_LN2); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
135 } |
7740 | 136 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
137 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
138 log2 (const Complex& x, int& exp) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
139 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
140 double ax = std::abs (x); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
141 double lax = log2 (ax, exp); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
142 return (ax != lax) ? (x / ax) * lax : x; |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
143 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
144 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
145 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
146 log2 (const FloatComplex& x, int& exp) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
147 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
148 float ax = std::abs (x); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
149 float lax = log2 (ax, exp); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
150 return (ax != lax) ? (x / ax) * lax : x; |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
151 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
152 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
153 bool negative_sign (double x) { return __lo_ieee_signbit (x); } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
154 bool negative_sign (float x) { return __lo_ieee_float_signbit (x); } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
155 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
156 // Sometimes you need a large integer, but not always. |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
157 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
158 octave_idx_type |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
159 nint_big (double x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
160 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
161 if (x > std::numeric_limits<octave_idx_type>::max ()) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
162 return std::numeric_limits<octave_idx_type>::max (); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
163 else if (x < std::numeric_limits<octave_idx_type>::min ()) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
164 return std::numeric_limits<octave_idx_type>::min (); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
165 else |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
166 return static_cast<octave_idx_type> ((x > 0.0) ? (x + 0.5) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
167 : (x - 0.5)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
168 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
169 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
170 octave_idx_type |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
171 nint_big (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
172 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
173 if (x > std::numeric_limits<octave_idx_type>::max ()) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
174 return std::numeric_limits<octave_idx_type>::max (); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
175 else if (x < std::numeric_limits<octave_idx_type>::min ()) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
176 return std::numeric_limits<octave_idx_type>::min (); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
177 else |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
178 return static_cast<octave_idx_type> ((x > 0.0f) ? (x + 0.5f) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
179 : (x - 0.5f)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
180 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
181 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
182 int |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
183 nint (double x) |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
18928
diff
changeset
|
184 { |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
185 if (x > std::numeric_limits<int>::max ()) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
186 return std::numeric_limits<int>::max (); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
187 else if (x < std::numeric_limits<int>::min ()) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
188 return std::numeric_limits<int>::min (); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
189 else |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
190 return static_cast<int> ((x > 0.0) ? (x + 0.5) : (x - 0.5)); |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
18928
diff
changeset
|
191 } |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
18928
diff
changeset
|
192 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
193 int |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
194 nint (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
195 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
196 if (x > std::numeric_limits<int>::max ()) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
197 return std::numeric_limits<int>::max (); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
198 else if (x < std::numeric_limits<int>::min ()) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
199 return std::numeric_limits<int>::min (); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
200 else |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
201 return static_cast<int> ((x > 0.0f) ? (x + 0.5f) : (x - 0.5f)); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
202 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
203 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
204 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
205 rc_acos (double x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
206 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
207 return fabs (x) > 1.0 ? acos (Complex (x)) : Complex (std::acos (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
208 } |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
18928
diff
changeset
|
209 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
210 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
211 rc_acos (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
212 { |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
213 return fabsf (x) > 1.0f ? acos (FloatComplex (x)) |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
214 : FloatComplex (std::acos (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
215 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
216 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
217 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
218 rc_acosh (double x) |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
18928
diff
changeset
|
219 { |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
220 return x < 1.0 ? acosh (Complex (x)) : Complex (acosh (x)); |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
18928
diff
changeset
|
221 } |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
222 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
223 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
224 rc_acosh (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
225 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
226 return x < 1.0f ? acosh (FloatComplex (x)) : FloatComplex (acosh (x)); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
227 } |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
18928
diff
changeset
|
228 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
229 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
230 rc_asin (double x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
231 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
232 return fabs (x) > 1.0 ? asin (Complex (x)) : Complex (std::asin (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
233 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
234 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
235 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
236 rc_asin (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
237 { |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
238 return fabsf (x) > 1.0f ? asin (FloatComplex (x)) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
239 : FloatComplex (::asinf (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
240 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
241 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
242 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
243 rc_atanh (double x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
244 { |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
245 return fabs (x) > 1.0 ? atanh (Complex (x)) : Complex (atanh (x)); |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
246 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
247 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
248 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
249 rc_atanh (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
250 { |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
251 return fabsf (x) > 1.0f ? atanh (FloatComplex (x)) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
252 : FloatComplex (atanh (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
253 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
254 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
255 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
256 rc_log (double x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
257 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
258 return x < 0.0 ? Complex (std::log (-x), M_PI) : Complex (std::log (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
259 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
260 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
261 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
262 rc_log (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
263 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
264 return x < 0.0f ? FloatComplex (std::log (-x), static_cast<float> (M_PI)) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
265 : FloatComplex (std::log (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
266 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
267 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
268 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
269 rc_log2 (double x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
270 { |
23761
102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
Rik <rik@octave.org>
parents:
23733
diff
changeset
|
271 constexpr double PI_LN2 = 4.53236014182719380962; // = pi / log(2) |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
272 return x < 0.0 ? Complex (log2 (-x), PI_LN2) : Complex (log2 (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
273 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
274 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
275 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
276 rc_log2 (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
277 { |
23761
102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
Rik <rik@octave.org>
parents:
23733
diff
changeset
|
278 constexpr float PI_LN2 = 4.53236014182719380962f; // = pi / log(2) |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
279 return x < 0.0f ? FloatComplex (log2 (-x), PI_LN2) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
280 : FloatComplex (log2 (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
281 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
282 |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
283 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
284 rc_log10 (double x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
285 { |
23761
102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
Rik <rik@octave.org>
parents:
23733
diff
changeset
|
286 constexpr double PI_LN10 = 1.36437635384184134748; // = pi / log(10) |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
287 return x < 0.0 ? Complex (log10 (-x), PI_LN10) : Complex (log10 (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
288 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
289 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
290 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
291 rc_log10 (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
292 { |
23761
102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
Rik <rik@octave.org>
parents:
23733
diff
changeset
|
293 constexpr float PI_LN10 = 1.36437635384184134748f; // = pi / log(10) |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23665
diff
changeset
|
294 return x < 0.0f ? FloatComplex (log10 (-x), PI_LN10) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
295 : FloatComplex (log10f (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
296 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
297 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
298 Complex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
299 rc_sqrt (double x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
300 { |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23643
diff
changeset
|
301 return x < 0.0 ? Complex (0.0, std::sqrt (-x)) : Complex (std::sqrt (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
302 } |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9319
diff
changeset
|
303 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
304 FloatComplex |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
305 rc_sqrt (float x) |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
306 { |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23643
diff
changeset
|
307 return x < 0.0f ? FloatComplex (0.0f, std::sqrt (-x)) |
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23643
diff
changeset
|
308 : FloatComplex (std::sqrt (x)); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
309 } |
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
310 } |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9319
diff
changeset
|
311 } |