Overload << operator for ckcomplex
authorAnshu Arya <arya3@illinois.edu>
Fri, 3 Sep 2010 17:51:28 +0000 (12:51 -0500)
committerAnshu Arya <arya3@illinois.edu>
Fri, 3 Sep 2010 18:21:33 +0000 (13:21 -0500)
Can now output ckcomplex using conventional operator to simplify
output of complex numbers.

src/util/ckcomplex.h

index 268f476d8f35953d5f8f73b84ad56eae65702fcb..0c627a507d71d80acae240b5f48cd2308631ad48 100644 (file)
@@ -11,6 +11,7 @@ typedef double     RealType;
 #endif
 
 #include <cmath>
+#include <ostream>
 
 struct ckcomplex {
     RealType  re;
@@ -89,6 +90,11 @@ struct ckcomplex {
     inline void operator delete[] (void *buf){
         free(buf);
     }
+
+    inline friend std::ostream& operator<< (std::ostream &out, const ckcomplex &aNum) {
+        out<<"("<<aNum.re<<","<<aNum.im<<")";
+        return out;
+    }
 };
 
 typedef ckcomplex complex;