Mercurial > octave
comparison liboctave/util/oct-cmplx.h @ 22197:e43d83253e28
refill multi-line macro definitions
Use the Emacs C++ mode style for line continuation markers in
multi-line macro definitions.
* make_int.cc, __dsearchn__.cc, __magick_read__.cc, besselj.cc,
bitfcns.cc, bsxfun.cc, cellfun.cc, data.cc, defun-dld.h, defun-int.h,
defun.h, det.cc, error.h, find.cc, gcd.cc, graphics.cc, interpreter.h,
jit-ir.h, jit-typeinfo.h, lookup.cc, ls-mat5.cc, max.cc, mexproto.h,
mxarray.in.h, oct-stream.cc, ordschur.cc, pr-output.cc, profiler.h,
psi.cc, regexp.cc, sparse-xdiv.cc, sparse-xpow.cc, tril.cc, txt-eng.h,
utils.cc, variables.cc, variables.h, xdiv.cc, xpow.cc, __glpk__.cc,
ov-base.cc, ov-base.h, ov-cell.cc, ov-ch-mat.cc, ov-classdef.cc,
ov-complex.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-float.cc, ov-float.h,
ov-flt-complex.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc,
ov-int-traits.h, ov-lazy-idx.h, ov-perm.cc, ov-re-mat.cc,
ov-re-sparse.cc, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc,
ov-type-conv.h, ov.cc, ov.h, op-class.cc, op-int-conv.cc, op-int.h,
op-str-str.cc, ops.h, lex.ll, Array.cc, CMatrix.cc, CSparse.cc,
MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse.h,
Sparse.cc, dMatrix.cc, dSparse.cc, fCMatrix.cc, fMatrix.cc,
idx-vector.cc, f77-fcn.h, quit.h, bsxfun-decl.h, bsxfun-defs.cc,
lo-specfun.cc, oct-convn.cc, oct-convn.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, Sparse-op-decls.h, Sparse-op-defs.h, mx-inlines.cc,
mx-op-decl.h, mx-op-defs.h, mach-info.cc, oct-group.cc, oct-passwd.cc,
oct-syscalls.cc, oct-time.cc, data-conv.cc, kpse.cc, lo-ieee.h,
lo-macros.h, oct-cmplx.h, oct-glob.cc, oct-inttypes.cc,
oct-inttypes.h, oct-locbuf.h, oct-sparse.h, url-transfer.cc,
oct-conf-post.in.h, shared-fcns.h: Refill macro definitions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 01 Aug 2016 12:40:18 -0400 |
parents | 1473547f50f5 |
children | bac0d6f07a3e |
comparison
equal
deleted
inserted
replaced
22196:dd992fd74fce | 22197:e43d83253e28 |
---|---|
40 | 40 |
41 // The standard C library function arg() returns [-pi,pi], which creates a | 41 // The standard C library function arg() returns [-pi,pi], which creates a |
42 // non-unique representation for numbers along the negative real axis branch | 42 // non-unique representation for numbers along the negative real axis branch |
43 // cut. Change this to principal value (-pi,pi] by mapping -pi to pi. | 43 // cut. Change this to principal value (-pi,pi] by mapping -pi to pi. |
44 | 44 |
45 #define DEF_COMPLEXR_COMP(OP, OPS) \ | 45 #define DEF_COMPLEXR_COMP(OP, OPS) \ |
46 template <typename T> \ | 46 template <typename T> \ |
47 inline bool operator OP (const std::complex<T>& a, const std::complex<T>& b) \ | 47 inline bool operator OP (const std::complex<T>& a, const std::complex<T>& b) \ |
48 { \ | 48 { \ |
49 OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ | 49 OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ |
50 OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ | 50 OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ |
51 if (ax == bx) \ | 51 if (ax == bx) \ |
52 { \ | 52 { \ |
53 OCTAVE_FLOAT_TRUNCATE const T ay = std::arg (a); \ | 53 OCTAVE_FLOAT_TRUNCATE const T ay = std::arg (a); \ |
54 OCTAVE_FLOAT_TRUNCATE const T by = std::arg (b); \ | 54 OCTAVE_FLOAT_TRUNCATE const T by = std::arg (b); \ |
55 if (ay == static_cast<T> (-M_PI)) \ | 55 if (ay == static_cast<T> (-M_PI)) \ |
56 { \ | 56 { \ |
57 if (by != static_cast<T> (-M_PI)) \ | 57 if (by != static_cast<T> (-M_PI)) \ |
58 return static_cast<T> (M_PI) OP by; \ | 58 return static_cast<T> (M_PI) OP by; \ |
59 } \ | 59 } \ |
60 else if (by == static_cast<T> (-M_PI)) \ | 60 else if (by == static_cast<T> (-M_PI)) \ |
61 { \ | 61 { \ |
62 return ay OP static_cast<T> (M_PI); \ | 62 return ay OP static_cast<T> (M_PI); \ |
63 } \ | 63 } \ |
64 return ay OP by; \ | 64 return ay OP by; \ |
65 } \ | 65 } \ |
66 else \ | 66 else \ |
67 return ax OPS bx; \ | 67 return ax OPS bx; \ |
68 } \ | 68 } \ |
69 template <typename T> \ | 69 template <typename T> \ |
70 inline bool operator OP (const std::complex<T>& a, T b) \ | 70 inline bool operator OP (const std::complex<T>& a, T b) \ |
71 { \ | 71 { \ |
72 OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ | 72 OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ |
73 OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ | 73 OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ |
74 if (ax == bx) \ | 74 if (ax == bx) \ |
75 { \ | 75 { \ |
76 OCTAVE_FLOAT_TRUNCATE const T ay = std::arg (a); \ | 76 OCTAVE_FLOAT_TRUNCATE const T ay = std::arg (a); \ |
77 if (ay == static_cast<T> (-M_PI)) \ | 77 if (ay == static_cast<T> (-M_PI)) \ |
78 return static_cast<T> (M_PI) OP 0; \ | 78 return static_cast<T> (M_PI) OP 0; \ |
79 return ay OP 0; \ | 79 return ay OP 0; \ |
80 } \ | 80 } \ |
81 else \ | 81 else \ |
82 return ax OPS bx; \ | 82 return ax OPS bx; \ |
83 } \ | 83 } \ |
84 template <typename T> \ | 84 template <typename T> \ |
85 inline bool operator OP (T a, const std::complex<T>& b) \ | 85 inline bool operator OP (T a, const std::complex<T>& b) \ |
86 { \ | 86 { \ |
87 OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ | 87 OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ |
88 OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ | 88 OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ |
89 if (ax == bx) \ | 89 if (ax == bx) \ |
90 { \ | 90 { \ |
91 OCTAVE_FLOAT_TRUNCATE const T by = std::arg (b); \ | 91 OCTAVE_FLOAT_TRUNCATE const T by = std::arg (b); \ |
92 if (by == static_cast<T> (-M_PI)) \ | 92 if (by == static_cast<T> (-M_PI)) \ |
93 return 0 OP static_cast<T> (M_PI); \ | 93 return 0 OP static_cast<T> (M_PI); \ |
94 return 0 OP by; \ | 94 return 0 OP by; \ |
95 } \ | 95 } \ |
96 else \ | 96 else \ |
97 return ax OPS bx; \ | 97 return ax OPS bx; \ |
98 } | 98 } |
99 | 99 |
100 DEF_COMPLEXR_COMP (>, >) | 100 DEF_COMPLEXR_COMP (>, >) |
101 DEF_COMPLEXR_COMP (<, <) | 101 DEF_COMPLEXR_COMP (<, <) |
102 DEF_COMPLEXR_COMP (<=, <) | 102 DEF_COMPLEXR_COMP (<=, <) |
103 DEF_COMPLEXR_COMP (>=, >) | 103 DEF_COMPLEXR_COMP (>=, >) |