22//
33// complex.h: Rcpp R/C++ interface class library -- binary operators for Rcomplex
44//
5- // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
5+ // Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
66//
77// This file is part of Rcpp.
88//
2222#ifndef RCPP__complex_H
2323#define RCPP__complex_H
2424
25- inline Rcomplex operator *( const Rcomplex& lhs, const Rcomplex& rhs){
25+ inline Rcomplex operator *( const Rcomplex& lhs, const Rcomplex& rhs) {
2626 Rcomplex y ;
2727 y.r = lhs.r * rhs.r - lhs.i * rhs.i ;
2828 y.i = lhs.r * rhs.i + rhs.r * lhs.i ;
2929 return y ;
3030}
31- inline Rcomplex operator +( const Rcomplex& lhs, const Rcomplex& rhs){
31+
32+ inline Rcomplex operator +( const Rcomplex& lhs, const Rcomplex& rhs) {
3233 Rcomplex y ;
3334 y.r = lhs.r + rhs.r ;
3435 y.i = lhs.i + rhs.i ;
3536 return y ;
3637}
37- inline Rcomplex operator -( const Rcomplex& lhs, const Rcomplex& rhs){
38+
39+ inline Rcomplex operator -( const Rcomplex& lhs, const Rcomplex& rhs) {
3840 Rcomplex y ;
3941 y.r = lhs.r - rhs.r ;
4042 y.i = lhs.i - rhs.i ;
4143 return y ;
4244}
43- inline Rcomplex operator /( const Rcomplex& a, const Rcomplex& b){
45+
46+ inline Rcomplex operator /( const Rcomplex& a, const Rcomplex& b) {
4447 Rcomplex c ;
4548 double ratio, den;
4649 double abr, abi;
@@ -61,12 +64,18 @@ inline Rcomplex operator/( const Rcomplex& a, const Rcomplex& b){
6164 return c ;
6265
6366}
64- inline bool operator ==( const Rcomplex& a, const Rcomplex& b){
67+
68+ inline bool operator ==( const Rcomplex& a, const Rcomplex& b) {
6569 return a.r == b.r && a.i == b.i ;
6670}
6771
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) {
6977 return os << cplx.r << " +" << cplx.i << " i" ;
7078}
7179
80+
7281#endif
0 commit comments