MADNESS  version 0.9
print.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 
31 
32  $Id$
33 */
34 
35 
36 #ifndef MADNESS_WORLD_PRINT_H__INCLUDED
37 #define MADNESS_WORLD_PRINT_H__INCLUDED
38 
41 
42 
43 #include <iostream>
44 #include <complex>
45 #include <list>
46 #include <vector>
49 
50 #ifdef BRAINDEAD
51 // Cray XT nonsense
52 #define ENDL "\n"
53 
54 #else
55 
56 #define ENDL std::endl
57 
58 #endif
59 
60 
61 namespace madness {
62 
64  template <typename T>
65  std::ostream& operator<<(std::ostream& s, const std::complex<T>& c) {
66  s << c.real() << "+" << c.imag() << "j";
67  return s;
68  }
69 
71  template <typename T, typename U>
72  std::ostream& operator<<(std::ostream& s, const std::pair<T,U>& p) {
73  s << "(" << p.first << "," << p.second << ")";
74  return s;
75  }
76 
78  template <typename T>
79  std::ostream& operator<<(std::ostream& s, const std::list<T>& c) {
80  s << "[";
81  typename std::list<T>::const_iterator it = c.begin();
82  while (it != c.end()) {
83  s << *it;
84  ++it;
85  if (it != c.end()) s << ", ";
86  };
87  s << "]";
88  return s;
89  }
90 
92  template <typename T>
93  std::ostream& operator<<(std::ostream& s, const std::vector<T>& c) {
94  s << "[";
95  typename std::vector<T>::const_iterator it = c.begin();
96  while (it != c.end()) {
97  s << *it;
98  ++it;
99  if (it != c.end()) s << ", ";
100  };
101  s << "]";
102  return s;
103  }
104 
106 
108  template <typename T, std::size_t N>
109  typename disable_if<std::is_same<T,char>, std::ostream&>::type
110  operator<<(std::ostream& s, const T(&v)[N]) {
111  s << "[";
112  for (std::size_t i=0; i<N; ++i) {
113  s << v[i];
114  if (i != (N-1)) s << ",";
115  }
116  s << "]";
117  return s;
118  }
119 
121  template <class A>
122  void print(const A& a) {
123  std::cout << a << ENDL;
124  }
125 
127  template <class A, class B>
128  void print(const A& a, const B& b) {
129  std::cout << a << " " << b << ENDL;
130  }
131 
133  template <class A, class B, class C>
134  void print(const A& a, const B& b, const C& c) {
135  std::cout << a << " " << b << " " << c << ENDL;
136  }
137 
139  template <class A, class B, class C, class D>
140  void print(const A& a, const B& b, const C& c, const D& d) {
141  std::cout << a << " " << b << " " << c << " " << d << ENDL;
142  }
143 
145  template <class A, class B, class C, class D, class E>
146  void print(const A& a, const B& b, const C& c, const D& d, const E& e) {
147  std::cout << a << " " << b << " " << c << " " << d << " " << e << ENDL;
148  }
149 
151  template <class A, class B, class C, class D, class E, class F>
152  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f) {
153  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << ENDL;
154  }
155 
157  template <class A, class B, class C, class D, class E, class F, class G>
158  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g) {
159  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << ENDL;
160  }
161 
163  template <class A, class B, class C, class D, class E, class F, class G, class H>
164  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h) {
165  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << ENDL;
166  }
167 
169  template <class A, class B, class C, class D, class E, class F, class G, class H, class I>
170  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i) {
171  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << ENDL;
172  }
173 
175  template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J>
176  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i, const J& j) {
177  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << " " << j << ENDL;
178  }
179 
181  template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K>
182  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i, const J& j, const K& k) {
183  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << " " << j << " " << k << ENDL;
184  }
185 
187  template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L>
188  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i, const J& j, const K& k, const L& l) {
189  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << " " << j << " " << k << " " << l << ENDL;
190  }
191 
193  template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M>
194  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i, const J& j, const K& k, const L& l, const M& m) {
195  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << " " << j << " " << k << " " << l << " " << m << ENDL;
196  }
197 
199  template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M, class N>
200  void print(const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i, const J& j, const K& k, const L& l, const M& m, const N& n) {
201  std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << " " << j << " " << k << " " << l << " " << m << " " << n << ENDL;
202  }
203 
205  void print_justified(const char* s, int column=0, bool underline=true);
206 
208  void print_centered(const char* s, int column=40, bool underline=true);
209 
210 }
211 #endif // MADNESS_WORLD_PRINT_H__INCLUDED
Tensor< double > B
Definition: tdse1d.cc:167
NDIM const Function< R, NDIM > & g
Definition: mra.h:2179
Grossly simplified Boost-like type traits and templates.
NDIM & f
Definition: mra.h:2179
JLOOP2 NK jnz KLOOP2 mov C
Definition: mtxm_gen.h:10
pcomplex_operatorT G
Definition: tdse1d.cc:168
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
void print_justified(const char *s, int column, bool underline)
Print a string justified on the left to start at the given column with optional underlining.
Definition: print.cc:38
const complexd I(0, 1)
const double m
Definition: gfit.cc:199
void print_centered(const char *s, int column, bool underline)
Print a string centered at the given column with optional underlining.
Definition: print.cc:48
std::ostream & operator<<(std::ostream &s, const ContractedGaussianShell &c)
Definition: chem/molecularbasis.cc:38
void print(const A &a)
Print a single item to std::cout terminating with new line.
Definition: print.h:122
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
const double c
Definition: gfit.cc:200
FLOAT b(int j, FLOAT z)
Definition: y1.cc:79