QUDA  v1.1.0
A library for QCD on GPUs
short.h
Go to the documentation of this file.
1 #ifndef _SHORT_H
2 #define _SHORT_H
3 
4 #define SHORT_LENGTH 65536
5 #define SCALE_FLOAT ((SHORT_LENGTH-1) * 0.5)
6 #define SHIFT_FLOAT (-1.f / (SHORT_LENGTH-1))
7 
8 template <typename Float>
9 inline short FloatToShort(Float a) {
10  //return (short)(a*MAX_SHORT);
11  short rtn = (short)((a+SHIFT_FLOAT)*SCALE_FLOAT);
12  return rtn;
13 }
14 
15 template <typename Float>
16 inline Float shortToFloat(short a) {
17  Float rtn = (float)a/SCALE_FLOAT - SHIFT_FLOAT;
18  return rtn;
19 }
20 
21 #endif // _SHORT_H
FloatingPoint< float > Float
short FloatToShort(Float a)
Definition: short.h:9
#define SCALE_FLOAT
Definition: short.h:5
Float shortToFloat(short a)
Definition: short.h:16
#define SHIFT_FLOAT
Definition: short.h:6