Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2015-11-13 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/complex.h: Define a header guard for dplyr to
prevent errorneous redefinition of operator<<() via dplyr

2015-11-11 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/vector/Matrix.h: Further simplification
Expand Down
23 changes: 16 additions & 7 deletions inst/include/Rcpp/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// complex.h: Rcpp R/C++ interface class library -- binary operators for Rcomplex
//
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
Expand All @@ -22,25 +22,28 @@
#ifndef RCPP__complex_H
#define RCPP__complex_H

inline Rcomplex operator*( const Rcomplex& lhs, const Rcomplex& rhs){
inline Rcomplex operator*( const Rcomplex& lhs, const Rcomplex& rhs) {
Rcomplex y ;
y.r = lhs.r * rhs.r - lhs.i * rhs.i ;
y.i = lhs.r * rhs.i + rhs.r * lhs.i ;
return y ;
}
inline Rcomplex operator+( const Rcomplex& lhs, const Rcomplex& rhs){

inline Rcomplex operator+( const Rcomplex& lhs, const Rcomplex& rhs) {
Rcomplex y ;
y.r = lhs.r + rhs.r ;
y.i = lhs.i + rhs.i ;
return y ;
}
inline Rcomplex operator-( const Rcomplex& lhs, const Rcomplex& rhs){

inline Rcomplex operator-( const Rcomplex& lhs, const Rcomplex& rhs) {
Rcomplex y ;
y.r = lhs.r - rhs.r ;
y.i = lhs.i - rhs.i ;
return y ;
}
inline Rcomplex operator/( const Rcomplex& a, const Rcomplex& b){

inline Rcomplex operator/( const Rcomplex& a, const Rcomplex& b) {
Rcomplex c ;
double ratio, den;
double abr, abi;
Expand All @@ -61,12 +64,18 @@ inline Rcomplex operator/( const Rcomplex& a, const Rcomplex& b){
return c ;

}
inline bool operator==( const Rcomplex& a, const Rcomplex& b){

inline bool operator==( const Rcomplex& a, const Rcomplex& b) {
return a.r == b.r && a.i == b.i ;
}

inline std::ostream & operator<<(std::ostream &os, const Rcomplex& cplx ){
// to prevent a redefinition error in dplyr (<= 0.4.3) which has the _same_
// definition of operator<<() for Rcomplex
#define dplyr_tools_complex_H

inline std::ostream & operator<<(std::ostream &os, const Rcomplex& cplx) {
return os << cplx.r << "+" << cplx.i << "i" ;
}


#endif