QUDA v0.4.0
A library for QCD on GPUs
quda/tests/short.h
Go to the documentation of this file.
00001 #ifndef _SHORT_H
00002 #define _SHORT_H
00003 
00004 #define SHORT_LENGTH 65536
00005 #define SCALE_FLOAT ((SHORT_LENGTH-1) * 0.5)
00006 #define SHIFT_FLOAT (-1.f / (SHORT_LENGTH-1))
00007 
00008 template <typename Float>
00009 inline short FloatToShort(Float a) {
00010   //return (short)(a*MAX_SHORT);
00011   short rtn = (short)((a+SHIFT_FLOAT)*SCALE_FLOAT);
00012   return rtn;
00013 }
00014 
00015 template <typename Float>
00016 inline Float shortToFloat(short a) {
00017   Float rtn = (float)a/SCALE_FLOAT - SHIFT_FLOAT;
00018   return rtn;
00019 }
00020 
00021 #endif // _SHORT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines