29 #ifndef _chemistry_qc_scf_cadf_macros_h
30 #define _chemistry_qc_scf_cadf_macros_h
33 #define DECLARE_ATTRIBUTE_LESS_STRUCT_NAMED(struct_name, attr_name) \
34 template<typename T> \
37 bool operator()(const T& a, const T& b) const { \
38 return a.##attr_name < b.##attr_name; \
41 #define DECLARE_ATTRIBUTE_LESS_STRUCT(attr_name) \
42 DECLARE_ATTRIBUTE_LESS_STRUCT_NAMED(attr_name##_less, attr_name)
45 #define M_DUMP(M) std::cout << #M << " is " << M.rows() << " x " << M.cols() << std::endl;
47 #define M_ELEM_DUMP(M, r, c) \
48 ExEnv::out0() << #M << " is " << M.rows() << " x " << M.cols() << ", trying to access element (" \
49 << r << ", " << c << ")." << std::endl;
51 #define M_ROW_ASSERT(M1, M2) \
52 if(M1.rows() != M2.rows()) { \
53 boost::lock_guard<boost::mutex> _tmp(debug_print_mutex); \
54 cout << "assertion failed. Rows not equal: M1 => " << M1.rows() << " x " << M1.cols() << ", M2 => " << M2.rows() << " x " << M2.cols() << endl; \
57 #define M_COL_ASSERT(M1, M2) \
58 if(M1.cols() != M2.cols()) { \
59 boost::lock_guard<boost::mutex> _tmp(debug_print_mutex); \
60 cout << "assertion failed. Cols not equal: M1 => " << M1.rows() << " x " << M1.cols() << ", M2 => " << M2.rows() << " x " << M2.cols() << endl; \
64 #define M_PROD_CHECK(R, M1, M2) \
65 if(R.rows() != M1.rows() || R.cols() != M2.cols() || M1.cols() != M2.rows()) { \
66 boost::lock_guard<boost::mutex> _tmp(debug_print_mutex); \
67 cout << "can't perform multiplication: (" << R.rows() << " x " << R.cols() << ") = (" << M1.rows() << " x " << M1.cols() << ") * (" << M2.rows() << " x " << M2.cols() << ")" << endl; \
71 #define M_DOT_CHECK(M1, M2) \
72 if(1 != M1.rows() || 1 != M2.cols() || M1.cols() != M2.rows()) { \
73 boost::lock_guard<boost::mutex> _tmp(debug_print_mutex); \
74 cout << "can't perform multiplication: (" << 1 << " x " << 1 << ") = (" << M1.rows() << " x " << M1.cols() << ") * (" << M2.rows() << " x " << M2.cols() << ")" << endl; \
78 #define DECOMP_PRINT(D, M) \
80 boost::lock_guard<boost::mutex> _tmp(debug_print_mutex); \
81 cout << "Decomposition: " << D.matrixQR().rows() << " x " << D.matrixQR().cols() << ", M => " << M.rows() << " x " << M.cols() << endl; \
84 #define M_EQ_ASSERT(M1, M2) M_ROW_ASSERT(M1, M2); M_COL_ASSERT(M1, M2);
86 #define M_BLOCK_ASSERT(M, b1a, b1b, b2a, b2b) \
88 std::cout << "assertion 1 failed. data: " << "(" << M.rows() << ", " << M.cols() << ", " << b1a << ", " << b1b << ", " << b2a << ", " << b2b << ")" << std::endl; \
91 std::cout << "assertion 2 failed. data: " << "(" << M.rows() << ", " << M.cols() << ", " << b1a << ", " << b1b << ", " << b2a << ", " << b2b << ")" << std::endl; \
93 else if(b1a > M.rows() - b2a) { \
94 std::cout << "assertion 3 failed. data: " << "(" << M.rows() << ", " << M.cols() << ", " << b1a << ", " << b1b << ", " << b2a << ", " << b2b << ")" << std::endl; \
96 else if(b1b > M.cols() - b2b) { \
97 std::cout << "assertion 4 failed. data: " << "(" << M.rows() << ", " << M.cols() << ", " << b1a << ", " << b1b << ", " << b2a << ", " << b2b << ")" << std::endl; \
100 #define DUMP(expr) sc::ExEnv::out0() << #expr << " = " << (expr) << std::endl;
101 #define DUMPme(expr) sc::ExEnv::outn() << " Node " << scf_grp_->me() << ": " << #expr << " = " << (expr) << std::endl;
102 #define DUMPn(expr) \
105 sc::ExEnv::out0() << "Dumping expression " << #expr << " from all nodes:" << std::endl; \
106 for(int __inode = 0; __inode < scf_grp_->n(); ++__inode) {\
107 if(__inode == scf_grp_->me()) { \
108 sc::ExEnv::outn() << " Node " << scf_grp_->me() << ": " << #expr << " = " << expr << std::endl; \
112 #define DUMP2(expr1, expr2) sc::ExEnv::out0() << #expr1 << " = " << (expr1) << ", " << #expr2 << " = " << (expr2) << std::endl;
113 #define DUMP2n(expr1, expr2) sc::ExEnv::outn() << "me = " << scf_grp_->me() << ", " << #expr1 << " = " << (expr1) << ", " << #expr2 << " = " << (expr2) << std::endl;
114 #define DUMP3(expr1, expr2, expr3) sc::ExEnv::out0() << #expr1 << " = " << (expr1) << ", " << #expr2 << " = " << (expr2) << ", " << #expr3 << " = " << (expr3) << std::endl;
115 #define DUMP4(expr1, expr2, expr3, expr4) ExEnv::out0() << #expr1 << " = " << (expr1) << ", " << #expr2 << " = " << (expr2) << ", " << #expr3 << " = " << (expr3) << ", " << #expr4 << " = " << (expr4) << std::endl;
116 #define DUMP5(expr1, expr2, expr3, expr4, expr5) std::cout << #expr1 << " = " << (expr1) << ", " << #expr2 << " = " << (expr2) << ", " << #expr3 << " = " << (expr3) << ", " << #expr4 << " = " << (expr4) << ", " << #expr5 << " = " << (expr5) << std::endl;
117 #define out_assert(a, op, b) assert(a op b || ((ExEnv::out0() << "Failed assertion output: " << #a << " ( = " << a << ") " << #op << " " << #b << " ( = " << b << ")" << std::endl), false))
118 #define DEBUG_DELETE_THIS
120 #define resize_and_zero_matrix(mat, nrows, ncols) mat.resize(nrows, ncols); mat = std::remove_reference<decltype(mat)>::type::Zero(nrows, ncols)
121 #define declare_and_zero_matrix(type, mat, nrows, ncols) type mat(nrows, ncols); mat = type::Zero(nrows, ncols)
123 #define MAKE_MATRIX(type, name, rows, cols) type name(rows, cols); auto __##name##_mem_holder = hold_memory(rows*cols*sizeof(Eigen::internal::traits<type>::Scalar) + sizeof(type));
134 #define PRINT_STRING_AS_GRID(o, itervar, iterable, str, nperline) \
135 { int __numdone = 0; \
136 for(auto&& itervar : iterable) { \
137 if(__numdone != 0 && __numdone % nperline == 0) { o << std::endl << sc::indent; } \
143 #define PRINT_AS_GRID(o, itervar, iterable, expr, fmt, nperline) PRINT_STRING_AS_GRID(o, itervar, iterable, (std::string(sc::scprintf(fmt, (expr)).str())), nperline)
Generated at Sun Jan 26 2020 23:23:57 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.