2
2
//
3
3
// complex.h: Rcpp R/C++ interface class library -- binary operators for Rcomplex
4
4
//
5
- // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
5
+ // Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
6
6
//
7
7
// This file is part of Rcpp.
8
8
//
22
22
#ifndef RCPP__complex_H
23
23
#define RCPP__complex_H
24
24
25
- inline Rcomplex operator *( const Rcomplex& lhs, const Rcomplex& rhs){
25
+ inline Rcomplex operator *( const Rcomplex& lhs, const Rcomplex& rhs) {
26
26
Rcomplex y ;
27
27
y.r = lhs.r * rhs.r - lhs.i * rhs.i ;
28
28
y.i = lhs.r * rhs.i + rhs.r * lhs.i ;
29
29
return y ;
30
30
}
31
- inline Rcomplex operator +( const Rcomplex& lhs, const Rcomplex& rhs){
31
+
32
+ inline Rcomplex operator +( const Rcomplex& lhs, const Rcomplex& rhs) {
32
33
Rcomplex y ;
33
34
y.r = lhs.r + rhs.r ;
34
35
y.i = lhs.i + rhs.i ;
35
36
return y ;
36
37
}
37
- inline Rcomplex operator -( const Rcomplex& lhs, const Rcomplex& rhs){
38
+
39
+ inline Rcomplex operator -( const Rcomplex& lhs, const Rcomplex& rhs) {
38
40
Rcomplex y ;
39
41
y.r = lhs.r - rhs.r ;
40
42
y.i = lhs.i - rhs.i ;
41
43
return y ;
42
44
}
43
- inline Rcomplex operator /( const Rcomplex& a, const Rcomplex& b){
45
+
46
+ inline Rcomplex operator /( const Rcomplex& a, const Rcomplex& b) {
44
47
Rcomplex c ;
45
48
double ratio, den;
46
49
double abr, abi;
@@ -61,12 +64,18 @@ inline Rcomplex operator/( const Rcomplex& a, const Rcomplex& b){
61
64
return c ;
62
65
63
66
}
64
- inline bool operator ==( const Rcomplex& a, const Rcomplex& b){
67
+
68
+ inline bool operator ==( const Rcomplex& a, const Rcomplex& b) {
65
69
return a.r == b.r && a.i == b.i ;
66
70
}
67
71
68
- inline std::ostream & operator <<(std::ostream &os, const Rcomplex& cplx ){
72
+ // to prevent a redefinition error in dplyr (<= 0.4.3) which has the _same_
73
+ // definition of operator<<() for Rcomplex
74
+ #define dplyr_tools_complex_H
75
+
76
+ inline std::ostream & operator <<(std::ostream &os, const Rcomplex& cplx) {
69
77
return os << cplx.r << " +" << cplx.i << " i" ;
70
78
}
71
79
80
+
72
81
#endif
0 commit comments