46 #ifndef _PEXSI_ENVIRONMENT_HPP_
47 #define _PEXSI_ENVIRONMENT_HPP_
96 #define _DEBUGlevel_ DEBUG
103 #define _DEBUGlevel -1
118 #define FORTRAN(name) name
119 #define BLAS(name) name
120 #define LAPACK(name) name
122 #define FORTRAN(name) name##_
123 #define BLAS(name) name##_
124 #define LAPACK(name) name##_
127 typedef int64_t LongInt;
129 typedef std::complex<double> Complex;
131 typedef std::complex<double> Scalar;
133 typedef double Scalar;
137 extern std::ofstream statusOFS;
139 extern std::ofstream statOFS;
141 extern std::deque<int > gemm_stat;
144 #if defined(COMM_PROFILE) || defined(COMM_PROFILE_BCAST)
145 extern std::ofstream commOFS;
147 extern std::deque<int > comm_stat;
149 #define PROFILE_COMM(sender,receiver,tag,size)\
151 comm_stat.push_back(sender);\
152 comm_stat.push_back(receiver);\
153 comm_stat.push_back(tag);\
154 comm_stat.push_back(size);\
157 #define HEADER_COMM "Sender\tReceiver\tTag\tSize"
158 #define LINE_COMM(it) *it<<"\t"<<*(it+1)<<"\t"<<*(it+2)<<"\t"<<*(it+3)
162 #define PROFILE_COMM(sender,receiver,tag,size)
171 const Int I_ZERO = 0;
173 const Int I_MINUS_ONE = -1;
174 const Real D_ZERO = 0.0;
175 const Real D_ONE = 1.0;
176 const Real D_MINUS_ONE = -1.0;
177 const Complex Z_ZERO = Complex(0.0, 0.0);
178 const Complex Z_ONE = Complex(1.0, 0.0);
179 const Complex Z_MINUS_ONE = Complex(-1.0, 0.0);
180 const Complex Z_I = Complex(0.0, 1.0);
181 const Complex Z_MINUS_I = Complex(0.0, -1.0);
182 const Scalar SCALAR_ZERO =
static_cast<Scalar
>(0.0);
183 const Scalar SCALAR_ONE =
static_cast<Scalar
>(1.0);
184 const Scalar SCALAR_MINUS_ONE =
static_cast<Scalar
>(-1.0);
187 const T ZERO(){
return static_cast<T
>(0.0);};
189 const T ONE(){
return static_cast<T
>(1.0);};
191 const T MINUS_ONE(){
return static_cast<T
>(-1.0);};
193 const char UPPER =
'U';
194 const char LOWER =
'L';
198 const Real au2K = 315774.67;
199 const Real PI = 3.141592653589793;
214 inline void gdb_lock(){
215 static volatile int count=0;
216 static volatile int enabled=0;
218 pid_t pid = getpid();
220 statusOFS<<pid<<
" is locked "<<count<<std::endl;
221 volatile int lock = 1;
222 while (lock == 1 && enabled == 1){ }
224 statusOFS<<pid<<
" is unlocked "<<count<<std::endl;
230 inline void gdb_truelock(){
231 pid_t pid = getpid();
232 std::cout<<pid<<
" is locked "<<std::endl;
233 volatile int lock = 1;
235 std::cout<<pid<<
" is unlocked "<<std::endl;
244 void ErrorHandling(
const char * msg );
253 Int overflow( Int c ) {
return traits_type::not_eof(c); }
257 : std::ios(&nullStreamBuffer_), std::ostream(&nullStreamBuffer_)
269 int nSize = backtrace(array, 25);
270 char ** symbols = backtrace_symbols(array, nSize);
272 for (
int i = 0; i < nSize; i++)
274 std::cout << symbols[i] << std::endl;
286 inline Int iround(Real a){
288 if(a>0) b = (a-Int(a)<0.5)?Int(a):(Int(a)+1);
289 else b = (Int(a)-a<0.5)?Int(a):(Int(a)-1);
294 inline void OptionsCreate(Int argc,
char** argv, std::map<std::string,std::string>& options){
296 for(Int k=1; k<argc; k=k+2) {
297 options[ std::string(argv[k]) ] = std::string(argv[k+1]);
303 inline Int Size( std::stringstream& sstm ){
305 sstm.seekg (0, std::ios::end);
306 length = sstm.tellg();
307 sstm.seekg (0, std::ios::beg);
315 #endif // _PEXSI_ENVIRONMENT_HPP_
Definition: environment.hpp:251
Definition: environment.hpp:263
Definition: environment.hpp:249