/*************************************************************************** almost.h - description ------------------- begin : Thu Nov 14 14:23:41 2002 copyright : (C) 2002 by Cavalli Andrea author : $Author$ date : $Date$ id : $Id$ email : cavalli@bioc.unizh.ch **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef __ALMOST__ #define __ALMOST__ #include #include #include #include #include //conf struff #ifdef SSE_INVSQRT #include static inline float invsqrt(float f){ const float half=0.5; const float three=3.0; // __v4sf t1 = __builtin_ia32_loadss (&f); __m128 t1 = _mm_load_ss(&f); // __v4sf t2 = __builtin_ia32_rsqrtss(t1); __m128 t2 = _mm_rsqrt_ss(t1); float t = ((float *)(&t2))[0]; return (half*t*(three-((f*t)*t))); } static inline float invsqrtf(float f){ const float half=0.5; const float three=3.0; // __v4sf t1 = __builtin_ia32_loadss (&f); __m128 t1 = _mm_load_ss(&f); // __v4sf t2 = __builtin_ia32_rsqrtss(t1); __m128 t2 = _mm_rsqrt_ss(t1); float t = ((float *)(&t2))[0]; return (half*t*(three-((f*t)*t))); } #else #include static inline float invsqrt(float f){ return 1.0f/sqrt(f); } static inline float invsqrtf(float f){ return 1.0f/sqrt(f); } #endif #if 1 #include static inline void * memalign(size_t q,size_t bits){ return malloc(bits); } #endif #ifdef __cplusplus using namespace std; //STL #include #include #include #include #include #include #include #include #include //ALMOST #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif namespace Almost { //Type of molecule enum MoleculeKind { PROTEIN = 0, NUCLEIC_ACID, LIPID, SUGAR, SOLVENT }; //Chemistry // enum AtomKind { // C=0, // H, // N, // O, // P, // S, // Ag, // Al, // B, // Br, // Ca, // Cl, // D, // F, // Fe, // Hg, // I, // K, // Li, // Lp, // Na, // Si, // Se, // Te, // Zn // }; //Std AMONOACID enum NameSpace { CHARMM19 = 0, CHARMM22 }; static const double kbol = 1.987191e-03; static const double timefact = 0.0488882129; inline bool is_back_bone(string name){ size_t pos = name.find("/"); if(pos!=string::npos) name = string(name.begin()+pos,name.end()); if(name=="CA") return true; if(name=="N") return true; if(name=="+N") return true; if(name=="C") return true; if(name=="O") return true; return false; } inline bool is_side_chain(string name){ size_t pos = name.find("/"); if(pos!=string::npos) name = string(name.begin()+pos+1,name.end()); // if(name=="CA") return false; CA is SIDE CHAIN ATOM if(name=="N") return false; if(name=="+N") return false; if(name=="C") return false; if(name=="O") return false; return true; } struct CPUPlain {}; struct CPUSSE{}; enum { ENERGY, KELVIN }; // static ostream * aout__; //#define aout (*aout__) class almost { static ostream * out; // static almost *almost_p; static int verbose_; public: almost(){ verbose_ = 1; } ~almost(){ if(out!=&cout){ delete out; } } static void log(string f); static ostream & aout(){ return *out;} static int verbose(){ return verbose_;} static void verbose(int i){if(i<0) i=0; verbose_ = i;} }; #define aout almost::aout() } #else #ifdef ALMOST_FLOAT typedef float Real; #else typedef double Real; #endif #endif //__cplusplus #endif // ALMOST