Skip to content

Commit 526275e

Browse files
committed
Merge pull request #399 from RcppCore/bugfix/operator-rcomplex-redef
bug fix for dplyr interaction
2 parents 77b74b3 + da69e45 commit 526275e

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2015-11-13 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/complex.h: Define a header guard for dplyr to
4+
prevent errorneous redefinition of operator<<() via dplyr
5+
16
2015-11-11 Dirk Eddelbuettel <[email protected]>
27

38
* inst/include/Rcpp/vector/Matrix.h: Further simplification

inst/include/Rcpp/complex.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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
//
@@ -22,25 +22,28 @@
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

Comments
 (0)