-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGeneralUtility.h
More file actions
84 lines (69 loc) · 1.64 KB
/
GeneralUtility.h
File metadata and controls
84 lines (69 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef __GENERALUTILITY_H_CMC__
#define __GENERALUTILITY_H_CMC__
// Use iprint
#ifndef iprint
#define iprint(name) myprinter(#name, (name))
#endif
#include "itensor/all.h"
using namespace itensor;
using namespace std;
template <typename TType>
inline void myprinter (string name, const TType& value)
{
cout << name << endl;
cout << value << endl;
}
// Variadic function Template that takes
// variable number of arguments and prints
// all of them.
void variadic_print () {} // Terminate function
template <typename T, typename... Types>
void variadic_print(T var1, Types... var2)
{
cout << var1 << " ";
variadic_print (var2...);
}
#define mycheck(condition, message) mycheck_impl(condition, __func__, message)
template <typename TypeName>
inline void mycheck_impl (const TypeName& condition, const string& func_name, string message="")
{
if (!bool(condition))
{
cout << func_name << ": " << message << endl;
throw;
}
}
/*
template <typename ConditionT, typename... MessageT>
inline void mycheck (const ConditionT& condition, const MessageT& ...message,
const std::source_location& location = std::source_location::current())
{
if (!bool(condition))
{
cout << location.function_name() << ": ";
variadic_print (message...);
cout << endl;
throw;
}
}*/
namespace iutility {
inline complex<double> conjT (complex<double> a)
{
return std::conj(a);
}
inline double conjT (double a)
{
return a;
}
}
namespace iut {
inline complex<double> conj (complex<double> a)
{
return std::conj(a);
}
inline double conj (double a)
{
return a;
}
}
#endif