comparison liboctave/numeric/lo-mappers.cc @ 31607:aac27ad79be6 stable

maint: Re-indent code after switch to using namespace macros. * build-env.h, build-env.in.cc, Cell.h, __betainc__.cc, __eigs__.cc, __ftp__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __magick_read__.cc, __pchip_deriv__.cc, amd.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, dasrt.cc, data.cc, debug.cc, defaults.cc, defaults.h, det.cc, display.cc, display.h, dlmread.cc, dynamic-ld.cc, dynamic-ld.h, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, gsvd.cc, gtk-manager.cc, gtk-manager.h, help.cc, help.h, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-hdf5.cc, ls-mat4.cc, ls-mat5.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mexproto.h, mxarray.h, mxtypes.in.h, oct-errno.in.cc, oct-hdf5-types.cc, oct-hist.cc, oct-hist.h, oct-map.cc, oct-map.h, oct-opengl.h, oct-prcstrm.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, octave-default-image.h, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-output.cc, psi.cc, qr.cc, quadcc.cc, rand.cc, regexp.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xpow.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfns.cc, svd.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, __delaunayn__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audioread.cc, convhulln.cc, gzip.cc, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.h, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-intx.h, ov-java.cc, ov-lazy-idx.cc, ov-legacy-range.cc, ov-magic-int.cc, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.h, octave.cc, octave.h, op-b-sbm.cc, op-bm-sbm.cc, op-cs-scm.cc, op-fm-fcm.cc, op-fs-fcm.cc, op-s-scm.cc, op-scm-cs.cc, op-scm-s.cc, op-sm-cs.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, oct-lvalue.cc, oct-lvalue.h, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h: Re-indent code after switch to using namespace macros.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 18:02:15 -0800
parents e88a07dec498
children 597f3ee61a48
comparison
equal deleted inserted replaced
31605:e88a07dec498 31607:aac27ad79be6
41 41
42 OCTAVE_BEGIN_NAMESPACE(octave) 42 OCTAVE_BEGIN_NAMESPACE(octave)
43 43
44 OCTAVE_BEGIN_NAMESPACE(math) 44 OCTAVE_BEGIN_NAMESPACE(math)
45 45
46 bool 46 bool
47 isna (double x) 47 isna (double x)
48 { 48 {
49 return lo_ieee_is_NA (x); 49 return lo_ieee_is_NA (x);
50 } 50 }
51 51
52 bool 52 bool
53 isna (const Complex& x) 53 isna (const Complex& x)
54 { 54 {
55 return (isna (std::real (x)) || isna (std::imag (x))); 55 return (isna (std::real (x)) || isna (std::imag (x)));
56 } 56 }
57 57
58 bool 58 bool
59 isna (float x) 59 isna (float x)
60 { 60 {
61 return lo_ieee_is_NA (x); 61 return lo_ieee_is_NA (x);
62 } 62 }
63 63
64 bool 64 bool
65 isna (const FloatComplex& x) 65 isna (const FloatComplex& x)
66 { 66 {
67 return (isna (std::real (x)) || isna (std::imag (x))); 67 return (isna (std::real (x)) || isna (std::imag (x)));
68 } 68 }
69 69
70 bool 70 bool
71 is_NaN_or_NA (const Complex& x) 71 is_NaN_or_NA (const Complex& x)
72 { 72 {
73 return (isnan (std::real (x)) || isnan (std::imag (x))); 73 return (isnan (std::real (x)) || isnan (std::imag (x)));
74 } 74 }
75 75
76 bool 76 bool
77 is_NaN_or_NA (const FloatComplex& x) 77 is_NaN_or_NA (const FloatComplex& x)
78 { 78 {
79 return (isnan (std::real (x)) || isnan (std::imag (x))); 79 return (isnan (std::real (x)) || isnan (std::imag (x)));
80 } 80 }
81 81
82 // Matlab returns a different phase for acos, asin then std library 82 // Matlab returns a different phase for acos, asin then std library
83 // which requires a small function to remap the phase. 83 // which requires a small function to remap the phase.
84 Complex 84 Complex
85 acos (const Complex& x) 85 acos (const Complex& x)
86 { 86 {
87 Complex y = std::acos (x); 87 Complex y = std::acos (x);
88 88
89 if (std::imag (x) == 0.0 && std::real (x) > 1.0) 89 if (std::imag (x) == 0.0 && std::real (x) > 1.0)
90 return std::conj (y); 90 return std::conj (y);
91 else 91 else
92 return y; 92 return y;
93 } 93 }
94 94
95 FloatComplex 95 FloatComplex
96 acos (const FloatComplex& x) 96 acos (const FloatComplex& x)
97 { 97 {
98 FloatComplex y = std::acos (x); 98 FloatComplex y = std::acos (x);
99 99
100 if (std::imag (x) == 0.0f && std::real (x) > 1.0f) 100 if (std::imag (x) == 0.0f && std::real (x) > 1.0f)
101 return std::conj (y); 101 return std::conj (y);
102 else 102 else
103 return y; 103 return y;
104 } 104 }
105 105
106 Complex 106 Complex
107 asin (const Complex& x) 107 asin (const Complex& x)
108 { 108 {
109 Complex y = std::asin (x); 109 Complex y = std::asin (x);
110 110
111 if (std::imag (x) == 0.0 && std::real (x) > 1.0) 111 if (std::imag (x) == 0.0 && std::real (x) > 1.0)
112 return std::conj (y); 112 return std::conj (y);
113 else 113 else
114 return y; 114 return y;
115 } 115 }
116 116
117 FloatComplex 117 FloatComplex
118 asin (const FloatComplex& x) 118 asin (const FloatComplex& x)
119 { 119 {
120 FloatComplex y = std::asin (x); 120 FloatComplex y = std::asin (x);
121 121
122 if (std::imag (x) == 0.0f && std::real (x) > 1.0f) 122 if (std::imag (x) == 0.0f && std::real (x) > 1.0f)
123 return std::conj (y); 123 return std::conj (y);
124 else 124 else
125 return y; 125 return y;
126 } 126 }
127 127
128 double frexp (double x, int *expptr) 128 double frexp (double x, int *expptr)
129 { 129 {
130 return octave_frexp_wrapper (x, expptr); 130 return octave_frexp_wrapper (x, expptr);
131 } 131 }
132 132
133 float frexp (float x, int *expptr) 133 float frexp (float x, int *expptr)
134 { 134 {
135 return octave_frexpf_wrapper (x, expptr); 135 return octave_frexpf_wrapper (x, expptr);
136 } 136 }
137 137
138 Complex 138 Complex
139 log2 (const Complex& x) 139 log2 (const Complex& x)
140 { 140 {
141 return std::log (x) / M_LN2; 141 return std::log (x) / M_LN2;
142 } 142 }
143 143
144 FloatComplex 144 FloatComplex
145 log2 (const FloatComplex& x) 145 log2 (const FloatComplex& x)
146 { 146 {
147 return std::log (x) / static_cast<float> (M_LN2); 147 return std::log (x) / static_cast<float> (M_LN2);
148 } 148 }
149 149
150 double 150 double
151 log2 (double x, int& exp) 151 log2 (double x, int& exp)
152 { 152 {
153 return frexp (x, &exp); 153 return frexp (x, &exp);
154 } 154 }
155 155
156 float 156 float
157 log2 (float x, int& exp) 157 log2 (float x, int& exp)
158 { 158 {
159 return frexp (x, &exp); 159 return frexp (x, &exp);
160 } 160 }
161 161
162 Complex 162 Complex
163 log2 (const Complex& x, int& exp) 163 log2 (const Complex& x, int& exp)
164 { 164 {
165 double ax = std::abs (x); 165 double ax = std::abs (x);
166 double lax = log2 (ax, exp); 166 double lax = log2 (ax, exp);
167 return (ax != lax) ? (x / ax) * lax : x; 167 return (ax != lax) ? (x / ax) * lax : x;
168 } 168 }
169 169
170 FloatComplex 170 FloatComplex
171 log2 (const FloatComplex& x, int& exp) 171 log2 (const FloatComplex& x, int& exp)
172 { 172 {
173 float ax = std::abs (x); 173 float ax = std::abs (x);
174 float lax = log2 (ax, exp); 174 float lax = log2 (ax, exp);
175 return (ax != lax) ? (x / ax) * lax : x; 175 return (ax != lax) ? (x / ax) * lax : x;
176 } 176 }
177 177
178 bool negative_sign (double x) { return __lo_ieee_signbit (x); } 178 bool negative_sign (double x) { return __lo_ieee_signbit (x); }
179 bool negative_sign (float x) { return __lo_ieee_float_signbit (x); } 179 bool negative_sign (float x) { return __lo_ieee_float_signbit (x); }
180 180
181 // Sometimes you need a large integer, but not always. 181 // Sometimes you need a large integer, but not always.
182 182
183 octave_idx_type 183 octave_idx_type
184 nint_big (double x) 184 nint_big (double x)
185 { 185 {
186 static const double out_of_range_top 186 static const double out_of_range_top
187 = static_cast<double>(std::numeric_limits<octave_idx_type>::max ())+1.; 187 = static_cast<double>(std::numeric_limits<octave_idx_type>::max ())+1.;
188 if (x >= out_of_range_top) 188 if (x >= out_of_range_top)
189 return std::numeric_limits<octave_idx_type>::max (); 189 return std::numeric_limits<octave_idx_type>::max ();
190 else if (x < std::numeric_limits<octave_idx_type>::min ()) 190 else if (x < std::numeric_limits<octave_idx_type>::min ())
191 return std::numeric_limits<octave_idx_type>::min (); 191 return std::numeric_limits<octave_idx_type>::min ();
192 else 192 else
193 return static_cast<octave_idx_type> ((x > 0.0) ? (x + 0.5) 193 return static_cast<octave_idx_type> ((x > 0.0) ? (x + 0.5)
194 : (x - 0.5)); 194 : (x - 0.5));
195 } 195 }
196 196
197 octave_idx_type 197 octave_idx_type
198 nint_big (float x) 198 nint_big (float x)
199 { 199 {
200 static const float out_of_range_top 200 static const float out_of_range_top
201 = static_cast<float>(std::numeric_limits<octave_idx_type>::max ())+1.; 201 = static_cast<float>(std::numeric_limits<octave_idx_type>::max ())+1.;
202 if (x >= out_of_range_top) 202 if (x >= out_of_range_top)
203 return std::numeric_limits<octave_idx_type>::max (); 203 return std::numeric_limits<octave_idx_type>::max ();
204 else if (x < std::numeric_limits<octave_idx_type>::min ()) 204 else if (x < std::numeric_limits<octave_idx_type>::min ())
205 return std::numeric_limits<octave_idx_type>::min (); 205 return std::numeric_limits<octave_idx_type>::min ();
206 else 206 else
207 return static_cast<octave_idx_type> ((x > 0.0f) ? (x + 0.5f) 207 return static_cast<octave_idx_type> ((x > 0.0f) ? (x + 0.5f)
208 : (x - 0.5f)); 208 : (x - 0.5f));
209 } 209 }
210 210
211 int 211 int
212 nint (double x) 212 nint (double x)
213 { 213 {
214 if (x > std::numeric_limits<int>::max ()) 214 if (x > std::numeric_limits<int>::max ())
215 return std::numeric_limits<int>::max (); 215 return std::numeric_limits<int>::max ();
216 else if (x < std::numeric_limits<int>::min ()) 216 else if (x < std::numeric_limits<int>::min ())
217 return std::numeric_limits<int>::min (); 217 return std::numeric_limits<int>::min ();
218 else 218 else
219 return static_cast<int> ((x > 0.0) ? (x + 0.5) : (x - 0.5)); 219 return static_cast<int> ((x > 0.0) ? (x + 0.5) : (x - 0.5));
220 } 220 }
221 221
222 int 222 int
223 nint (float x) 223 nint (float x)
224 { 224 {
225 static const float out_of_range_top 225 static const float out_of_range_top
226 = static_cast<float>(std::numeric_limits<int>::max ()) + 1.; 226 = static_cast<float>(std::numeric_limits<int>::max ()) + 1.;
227 if (x >= out_of_range_top) 227 if (x >= out_of_range_top)
228 return std::numeric_limits<int>::max (); 228 return std::numeric_limits<int>::max ();
229 else if (x < std::numeric_limits<int>::min ()) 229 else if (x < std::numeric_limits<int>::min ())
230 return std::numeric_limits<int>::min (); 230 return std::numeric_limits<int>::min ();
231 else 231 else
232 return static_cast<int> ((x > 0.0f) ? (x + 0.5f) : (x - 0.5f)); 232 return static_cast<int> ((x > 0.0f) ? (x + 0.5f) : (x - 0.5f));
233 } 233 }
234 234
235 Complex 235 Complex
236 rc_acos (double x) 236 rc_acos (double x)
237 { 237 {
238 return fabs (x) > 1.0 ? acos (Complex (x)) : Complex (std::acos (x)); 238 return fabs (x) > 1.0 ? acos (Complex (x)) : Complex (std::acos (x));
239 } 239 }
240 240
241 FloatComplex 241 FloatComplex
242 rc_acos (float x) 242 rc_acos (float x)
243 { 243 {
244 return fabsf (x) > 1.0f ? acos (FloatComplex (x)) 244 return fabsf (x) > 1.0f ? acos (FloatComplex (x))
245 : FloatComplex (std::acos (x)); 245 : FloatComplex (std::acos (x));
246 } 246 }
247 247
248 Complex 248 Complex
249 rc_acosh (double x) 249 rc_acosh (double x)
250 { 250 {
251 return x < 1.0 ? acosh (Complex (x)) : Complex (acosh (x)); 251 return x < 1.0 ? acosh (Complex (x)) : Complex (acosh (x));
252 } 252 }
253 253
254 FloatComplex 254 FloatComplex
255 rc_acosh (float x) 255 rc_acosh (float x)
256 { 256 {
257 return x < 1.0f ? acosh (FloatComplex (x)) : FloatComplex (acosh (x)); 257 return x < 1.0f ? acosh (FloatComplex (x)) : FloatComplex (acosh (x));
258 } 258 }
259 259
260 Complex 260 Complex
261 rc_asin (double x) 261 rc_asin (double x)
262 { 262 {
263 return fabs (x) > 1.0 ? asin (Complex (x)) : Complex (std::asin (x)); 263 return fabs (x) > 1.0 ? asin (Complex (x)) : Complex (std::asin (x));
264 } 264 }
265 265
266 FloatComplex 266 FloatComplex
267 rc_asin (float x) 267 rc_asin (float x)
268 { 268 {
269 return fabsf (x) > 1.0f ? asin (FloatComplex (x)) 269 return fabsf (x) > 1.0f ? asin (FloatComplex (x))
270 : FloatComplex (::asinf (x)); 270 : FloatComplex (::asinf (x));
271 } 271 }
272 272
273 Complex 273 Complex
274 rc_atanh (double x) 274 rc_atanh (double x)
275 { 275 {
276 return fabs (x) > 1.0 ? atanh (Complex (x)) : Complex (atanh (x)); 276 return fabs (x) > 1.0 ? atanh (Complex (x)) : Complex (atanh (x));
277 } 277 }
278 278
279 FloatComplex 279 FloatComplex
280 rc_atanh (float x) 280 rc_atanh (float x)
281 { 281 {
282 return fabsf (x) > 1.0f ? atanh (FloatComplex (x)) 282 return fabsf (x) > 1.0f ? atanh (FloatComplex (x))
283 : FloatComplex (atanh (x)); 283 : FloatComplex (atanh (x));
284 } 284 }
285 285
286 Complex 286 Complex
287 rc_log (double x) 287 rc_log (double x)
288 { 288 {
289 return x < 0.0 ? Complex (std::log (-x), M_PI) : Complex (std::log (x)); 289 return x < 0.0 ? Complex (std::log (-x), M_PI) : Complex (std::log (x));
290 } 290 }
291 291
292 FloatComplex 292 FloatComplex
293 rc_log (float x) 293 rc_log (float x)
294 { 294 {
295 return x < 0.0f ? FloatComplex (std::log (-x), static_cast<float> (M_PI)) 295 return x < 0.0f ? FloatComplex (std::log (-x), static_cast<float> (M_PI))
296 : FloatComplex (std::log (x)); 296 : FloatComplex (std::log (x));
297 } 297 }
298 298
299 Complex 299 Complex
300 rc_log2 (double x) 300 rc_log2 (double x)
301 { 301 {
302 constexpr double PI_LN2 = 4.53236014182719380962; // = pi / log(2) 302 constexpr double PI_LN2 = 4.53236014182719380962; // = pi / log(2)
303 return x < 0.0 ? Complex (log2 (-x), PI_LN2) : Complex (log2 (x)); 303 return x < 0.0 ? Complex (log2 (-x), PI_LN2) : Complex (log2 (x));
304 } 304 }
305 305
306 FloatComplex 306 FloatComplex
307 rc_log2 (float x) 307 rc_log2 (float x)
308 { 308 {
309 constexpr float PI_LN2 = 4.53236014182719380962f; // = pi / log(2) 309 constexpr float PI_LN2 = 4.53236014182719380962f; // = pi / log(2)
310 return x < 0.0f ? FloatComplex (log2 (-x), PI_LN2) 310 return x < 0.0f ? FloatComplex (log2 (-x), PI_LN2)
311 : FloatComplex (log2 (x)); 311 : FloatComplex (log2 (x));
312 } 312 }
313 313
314 Complex 314 Complex
315 rc_log10 (double x) 315 rc_log10 (double x)
316 { 316 {
317 constexpr double PI_LN10 = 1.36437635384184134748; // = pi / log(10) 317 constexpr double PI_LN10 = 1.36437635384184134748; // = pi / log(10)
318 return x < 0.0 ? Complex (log10 (-x), PI_LN10) : Complex (log10 (x)); 318 return x < 0.0 ? Complex (log10 (-x), PI_LN10) : Complex (log10 (x));
319 } 319 }
320 320
321 FloatComplex 321 FloatComplex
322 rc_log10 (float x) 322 rc_log10 (float x)
323 { 323 {
324 constexpr float PI_LN10 = 1.36437635384184134748f; // = pi / log(10) 324 constexpr float PI_LN10 = 1.36437635384184134748f; // = pi / log(10)
325 return x < 0.0f ? FloatComplex (log10 (-x), PI_LN10) 325 return x < 0.0f ? FloatComplex (log10 (-x), PI_LN10)
326 : FloatComplex (log10f (x)); 326 : FloatComplex (log10f (x));
327 } 327 }
328 328
329 Complex 329 Complex
330 rc_sqrt (double x) 330 rc_sqrt (double x)
331 { 331 {
332 return x < 0.0 ? Complex (0.0, std::sqrt (-x)) : Complex (std::sqrt (x)); 332 return x < 0.0 ? Complex (0.0, std::sqrt (-x)) : Complex (std::sqrt (x));
333 } 333 }
334 334
335 FloatComplex 335 FloatComplex
336 rc_sqrt (float x) 336 rc_sqrt (float x)
337 { 337 {
338 return x < 0.0f ? FloatComplex (0.0f, std::sqrt (-x)) 338 return x < 0.0f ? FloatComplex (0.0f, std::sqrt (-x))
339 : FloatComplex (std::sqrt (x)); 339 : FloatComplex (std::sqrt (x));
340 } 340 }
341 341
342 OCTAVE_END_NAMESPACE(math) 342 OCTAVE_END_NAMESPACE(math)
343 OCTAVE_END_NAMESPACE(octave) 343 OCTAVE_END_NAMESPACE(octave)